ZQuest Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2024-06-14 07:26:05
Exec Total Coverage
Lines: 2007 4422 45.4%
Functions: 137 331 41.4%
Branches: 1331 3600 37.0%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/render.h"
6 #include "zalleg/zalleg.h"
7 #include "base/qrs.h"
8 #include "base/dmap.h"
9 #include <functional>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <cstring>
13 #include <math.h>
14 #include <map>
15 #include <filesystem>
16 #include <ctype.h>
17 #include <sstream>
18 #include "base/version.h"
19 #include "base/zc_alleg.h"
20 #include "gamedata.h"
21 #include "zc/zc_init.h"
22 #include "init.h"
23 #include "zc/replay.h"
24 #include "zc/cheats.h"
25 #include "zc/render.h"
26 #include "base/zc_math.h"
27 #include "base/zapp.h"
28 #include "dialog/cheatkeys.h"
29 #include "metadata/metadata.h"
30 #include "zc/zelda.h"
31 #include "zc/saves.h"
32 #include "tiles.h"
33 #include "base/colors.h"
34 #include "pal.h"
35 #include "base/zsys.h"
36 #include "qst.h"
37 #include "zc/zc_sys.h"
38 #include "play_midi.h"
39 #include "gui/jwin_a5.h"
40 #include "base/jwinfsel.h"
41 #include "base/gui.h"
42 #include "midi.h"
43 #include "subscr.h"
44 #include "zc/maps.h"
45 #include "sprite.h"
46 #include "zc/guys.h"
47 #include "zc/hero.h"
48 #include "zc/title.h"
49 #include "particles.h"
50 #include "sound/zcmusic.h"
51 #include "zconsole.h"
52 #include "zc/ffscript.h"
53 #include "dialog/info.h"
54 #include "dialog/alert.h"
55 #include "zc/combos.h"
56 #include "zc/jit.h"
57 #include "zc/zc_subscr.h"
58 #include <fmt/format.h>
59 #include "zinfo.h"
60 #include "base/misctypes.h"
61 #include "music_playback.h"
62 #include <base/new_menu.h>
63
64 #ifdef __EMSCRIPTEN__
65 #include "base/emscripten_utils.h"
66 #endif
67
68 using namespace std::chrono_literals;
69
70 extern FFScript FFCore;
71 extern bool Playing;
72 int32_t sfx_voice[WAV_COUNT];
73 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
74 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
75
76 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
77 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern zcmodule moduledata;
83 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
84 extern particle_list particles;
85 extern int32_t loadlast;
86 extern char *sfx_string[WAV_COUNT];
87 byte use_dwm_flush;
88 byte use_save_indicator;
89 int32_t paused_midi_pos = 0;
90 byte midi_suspended = 0;
91 byte zc_192b163_warp_compatibility;
92 char modulepath[2048];
93 bool epilepsyFlashReduction;
94 signed char pause_in_background_menu_init = 0;
95 byte pause_in_background = 0;
96 bool is_sys_pal = false;
97 static bool load_control_called_this_frame;
98 extern PALETTE* hw_palette;
99 extern bool update_hw_pal;
100 extern const char* dmaplist(int32_t index, int32_t* list_size);
101 int32_t getnumber(const char *prompt,int32_t initialval);
102
103 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
104 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
105
106 static const char *qst_module_name = "current_module";
107 #ifdef ALLEGRO_LINUX
108 static const char *samplepath = "samplesoundset/patches.dat";
109 #endif
110 char qst_files_path[2048];
111
112 extern TopMenu the_player_menu;
113 #ifdef _MSC_VER
114 #define getcwd _getcwd
115 #endif
116
117 bool rF11();
118 bool rI();
119 bool rQ();
120 bool zc_key_pressed();
121
122 #ifdef _WIN32
123
124 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
125 extern "C"
126 {
127 typedef HRESULT(WINAPI *t_DwmFlush)();
128 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
129 }
130
131 void do_DwmFlush()
132 {
133 static HMODULE shell = LoadLibrary("dwmapi.dll");
134
135 if(!shell)
136 return;
137
138 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
139 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
140
141 BOOL enabled;
142 isEnabled(&enabled);
143
144 if(isEnabled)
145 flush();
146 }
147
148 #endif // _WIN32
149
150 92829 bool flash_reduction_enabled(bool check_qr)
151 {
152
4/4
✓ Branch 0 taken 88404 times.
✓ Branch 1 taken 4425 times.
✓ Branch 2 taken 87576 times.
✓ Branch 3 taken 92001 times.
92829 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
153 }
154
155 // Dialogue largening
156 void large_dialog(DIALOG *d)
157 {
158 large_dialog(d, 1.5);
159 }
160
161 void large_dialog(DIALOG *d, float RESIZE_AMT)
162 {
163 if(!d[0].d1)
164 {
165 d[0].d1 = 1;
166 int32_t oldwidth = d[0].w;
167 int32_t oldheight = d[0].h;
168 int32_t oldx = d[0].x;
169 int32_t oldy = d[0].y;
170 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
171 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
172 d[0].w = int32_t(d[0].w*RESIZE_AMT);
173 d[0].h = int32_t(d[0].h*RESIZE_AMT);
174
175 for(int32_t i=1; d[i].proc !=NULL; i++)
176 {
177 // Place elements horizontally
178 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
179 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
180
181 if(d[i].proc != d_stringloader)
182 {
183 if(d[i].proc==d_bitmap_proc)
184 {
185 d[i].w *= 2;
186 }
187 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
188 }
189
190 // Place elements vertically
191 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
192 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
193
194 // Vertically resize elements
195 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
196 {
197 d[i].h = int32_t((double)d[i].h*1.5);
198 }
199 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
200 {
201 d[i].y += int32_t((double)d[i].h*0.25);
202 d[i].h = int32_t((double)d[i].h*1.25);
203 }
204 else if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].h *= 2;
207 }
208 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
209
210 // Fix frames
211 if(d[i].proc == jwin_frame_proc)
212 {
213 d[i].x++;
214 d[i].y++;
215 d[i].w-=4;
216 d[i].h-=4;
217 }
218 }
219 }
220
221 for(int32_t i=1; d[i].proc!=NULL; i++)
222 {
223 if(d[i].proc==jwin_slider_proc)
224 continue;
225
226 // Bigger font
227 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
228
229 if(!d[i].dp2 && bigfontproc)
230 {
231 d[i].dp2 = get_zc_font(font_lfont_l);
232 }
233 else if(!bigfontproc)
234 {
235 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
236 }
237
238 // Make checkboxes work
239 if(d[i].proc == jwin_check_proc)
240 d[i].proc = jwin_checkfont_proc;
241 else if(d[i].proc == jwin_radio_proc)
242 d[i].proc = jwin_radiofont_proc;
243 }
244
245 jwin_center_dialog(d);
246 }
247
248
249 /**********************************/
250 /******** System functions ********/
251 /**********************************/
252
253 static char cfg_sect[] = "zeldadx"; //We need to rename this.
254 static char ctrl_sect[] = "Controls";
255 static char sfx_sect[] = "Volume";
256
257 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
258 {
259 return D_O_K;
260 }
261
262 bool is_reserved_key(int c)
263 {
264 switch(c)
265 {
266 case KEY_ESC:
267 return true;
268 }
269 return false;
270 }
271 bool is_reserved_keycombo(int c, int modflag)
272 {
273 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
274 return true;
275 return false;
276 }
277 bool checkcheat(Cheat cheat)
278 {
279 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
280 return true; //Main key pressed
281 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
282 return true; //Alt key pressed
283 return false;
284 }
285 266 void load_default_cheatkeys()
286 {
287 266 memset(cheatkeys, 0, sizeof(cheatkeys));
288 266 cheatkeys[Cheat::Life][0] = KEY_H;
289 266 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
290 266 cheatkeys[Cheat::Magic][0] = KEY_M;
291 266 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
292 266 cheatkeys[Cheat::Rupies][0] = KEY_R;
293 266 cheatkeys[Cheat::Bombs][0] = KEY_B;
294 266 cheatkeys[Cheat::Arrows][0] = KEY_A;
295 266 cheatkeys[Cheat::Clock][0] = KEY_I;
296 266 cheatkeys[Cheat::Walls][0] = KEY_F11;
297 266 cheatkeys[Cheat::Fast][0] = KEY_Q;
298 266 cheatkeys[Cheat::Light][0] = KEY_L;
299 266 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
300 266 cheatkeys[Cheat::Kill][0] = KEY_K;
301 266 cheatkeys[Cheat::GoTo][0] = KEY_G;
302 266 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
303 266 cheatkeys[Cheat::ShowL0][0] = KEY_0;
304 266 cheatkeys[Cheat::ShowL1][0] = KEY_1;
305 266 cheatkeys[Cheat::ShowL2][0] = KEY_2;
306 266 cheatkeys[Cheat::ShowL3][0] = KEY_3;
307 266 cheatkeys[Cheat::ShowL4][0] = KEY_4;
308 266 cheatkeys[Cheat::ShowL5][0] = KEY_5;
309 266 cheatkeys[Cheat::ShowL6][0] = KEY_6;
310 266 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
311 266 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
312 266 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
313 266 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
314 266 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
315 266 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
316 266 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
317 266 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
318 266 }
319 266 void load_game_configs()
320 {
321 266 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"modules/classic.zmod"));
322 266 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
323 266 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
324 266 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
325 266 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
326 266 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
327 266 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
328 266 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
329 266 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
330 266 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
331 266 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
332 266 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
333 266 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
334 266 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
335 266 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
336
337 //cheat modifier keya
338 266 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
339 266 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
340 266 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
341 266 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
342
343 //cheat keys
344 266 load_default_cheatkeys();
345 char buf[256];
346
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 9576 times.
9842 for(size_t q = 1; q < Cheat::Last; ++q)
347 {
348
1/2
✓ Branch 0 taken 9576 times.
✗ Branch 1 not taken.
9576 if(!bindable_cheat((Cheat)q)) continue;
349 9576 std::string cheatname = cheat_to_string((Cheat)q);
350
1/2
✓ Branch 0 taken 9576 times.
✗ Branch 1 not taken.
9576 util::lowerstr(cheatname);
351 9576 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
352
1/2
✓ Branch 0 taken 9576 times.
✗ Branch 1 not taken.
9576 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
353 9576 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
354
1/2
✓ Branch 0 taken 9576 times.
✗ Branch 1 not taken.
9576 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
355 9576 }
356
357
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
358 joystick_index = 0;
359
360 266 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
361 266 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
362 266 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
363 266 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
364 266 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
365 266 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
366 266 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
367 266 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
368 266 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
369 266 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
370
371 266 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
372 266 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
373 266 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
374 266 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
375
376 266 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
377 266 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
378 266 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
379 266 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
380 266 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
381 266 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
382 266 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
383 266 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
384 266 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
385 266 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
386 266 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
387
388 266 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
389 266 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
390 266 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
391 266 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
392
393 266 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
394
395 266 midi_volume = zc_get_config(sfx_sect,"midi",255);
396 266 sfx_volume = zc_get_config(sfx_sect,"sfx",255);
397 266 emusic_volume = zc_get_config(sfx_sect,"emusic",255);
398 266 pan_style = zc_get_config(sfx_sect,"pan",1);
399 266 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
400 266 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
401 266 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
402 266 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
403 266 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
404 266 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
405 266 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
406 266 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
407 #ifdef __EMSCRIPTEN__
408 if (em_is_mobile()) NameEntryMode = 2;
409 #endif
410 266 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
411 266 ShowGameTime = zc_get_config(cfg_sect,"showtime",0);
412 266 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
413 266 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
414 266 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
415 266 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
416
417 266 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
418 266 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
419 266 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
420 266 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
421 266 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
422 266 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
423 266 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
424
425 266 loadlast = zc_get_config(cfg_sect,"load_last",0);
426
427 266 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
428
429 266 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
430 266 info_opacity = zc_get_config("zc","debug_info_opacity",255);
431 #ifdef _WIN32
432 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
433 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
434 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
435
436 // This one's for Aero
437 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
438
439 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
440 #else //UNIX
441 266 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
442 266 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
443 #endif
444 266 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
445 266 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
446
447 266 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
448 266 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
449 266 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
450 266 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
451 266 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
452 266 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
453 266 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
454 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
455 266 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
456 266 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
457 266 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
458 266 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
459 266 SkipTitle = zc_get_config(cfg_sect,"skip_title",0);
460 266 }
461
462 void save_control_configs(bool kb)
463 {
464 if(kb)
465 {
466 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
467 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
468 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
469 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
470
471 if (!replay_is_replaying())
472 {
473 zc_set_config(ctrl_sect,"key_a",Akey);
474 zc_set_config(ctrl_sect,"key_b",Bkey);
475 zc_set_config(ctrl_sect,"key_s",Skey);
476 zc_set_config(ctrl_sect,"key_l",Lkey);
477 zc_set_config(ctrl_sect,"key_r",Rkey);
478 zc_set_config(ctrl_sect,"key_p",Pkey);
479 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
480 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
481 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
482 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
483 zc_set_config(ctrl_sect,"key_up", DUkey);
484 zc_set_config(ctrl_sect,"key_down", DDkey);
485 zc_set_config(ctrl_sect,"key_left", DLkey);
486 zc_set_config(ctrl_sect,"key_right",DRkey);
487 }
488 }
489 else
490 {
491 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
492 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
493 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
494 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
495 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
496 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
497 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
498 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
499 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
500 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
501 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
502 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
503 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
504 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
505
506 zc_set_config(ctrl_sect,"btn_a",Abtn);
507 zc_set_config(ctrl_sect,"btn_b",Bbtn);
508 zc_set_config(ctrl_sect,"btn_s",Sbtn);
509 zc_set_config(ctrl_sect,"btn_m",Mbtn);
510 zc_set_config(ctrl_sect,"btn_l",Lbtn);
511 zc_set_config(ctrl_sect,"btn_r",Rbtn);
512 zc_set_config(ctrl_sect,"btn_p",Pbtn);
513 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
514 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
515 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
516 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
517
518 zc_set_config(ctrl_sect,"btn_up",DUbtn);
519 zc_set_config(ctrl_sect,"btn_down",DDbtn);
520 zc_set_config(ctrl_sect,"btn_left",DLbtn);
521 zc_set_config(ctrl_sect,"btn_right",DRbtn);
522 }
523 }
524
525 void save_cheatkeys()
526 {
527 char buf[256];
528 for(size_t q = 1; q < Cheat::Last; ++q)
529 {
530 if(!bindable_cheat((Cheat)q)) continue;
531 std::string cheatname = cheat_to_string((Cheat)q);
532 util::lowerstr(cheatname);
533 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
534 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
535 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
536 if(cheatkeys[q][1])
537 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
538 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
539 }
540 }
541
542 void save_game_configs()
543 {
544 packfile_password("");
545
546 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
547
548 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
549 {
550 int o_window_x, o_window_y;
551 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
552 zc_set_config(cfg_sect,"window_x",o_window_x);
553 zc_set_config(cfg_sect,"window_y",o_window_y);
554 }
555
556 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
557 {
558 window_width = al_get_display_width(all_get_display());
559 window_height = al_get_display_height(all_get_display());
560 zc_set_config(cfg_sect,"window_width",window_width);
561 zc_set_config(cfg_sect,"window_height",window_height);
562 }
563
564 zc_set_config(cfg_sect,"load_last",loadlast);
565 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
566
567 flush_config_file();
568 #ifdef __EMSCRIPTEN__
569 em_sync_fs();
570 #endif
571 }
572
573 //----------------------------------------------------------------
574
575 // Timers
576
577 43312 void fps_callback()
578 {
579 43312 lastfps=framecnt;
580 43312 framecnt=0;
581 43312 }
582
583 END_OF_FUNCTION(fps_callback)
584
585 266 int32_t Z_init_timers()
586 {
587 static bool didit = false;
588 const static char *err_str = "Couldn't allocate timer";
589 266 err_str = err_str; //Unused variable warning
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266 times.
266 if(didit)
592 return 1;
593
594 266 didit = true;
595
596 LOCK_VARIABLE(lastfps);
597 LOCK_VARIABLE(framecnt);
598 LOCK_FUNCTION(fps_callback);
599
600
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
601 return 0;
602
603 266 return 1;
604 266 }
605
606 void Z_remove_timers()
607 {
608 remove_int(fps_callback);
609 }
610
611 //----------------------------------------------------------------
612
613 void go()
614 {
615 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
616 }
617
618 void comeback()
619 {
620 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
621 }
622
623 void dump_pal(BITMAP *dest)
624 {
625 for(int32_t i=0; i<256; i++)
626 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
627 }
628
629 //----------------------------------------------------------------
630
631 int game_mouse_index = ZCM_BLANK;
632 static bool system_mouse = false;
633 176 bool sys_mouse()
634 {
635 176 system_mouse = true;
636 176 return MouseSprite::set(ZCM_NORMAL);
637 }
638 1574 bool game_mouse()
639 {
640 1574 system_mouse = false;
641 1574 return MouseSprite::set(game_mouse_index);
642 }
643 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
644 {
645 if(!bmp)
646 return;
647 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
648 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
649 if(bmp->w == scaledw && bmp->h == scaledh)
650 user_scale = false;
651 if(user_scale || sys_recolor)
652 {
653 if(!user_scale) scale = 1;
654 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
655 if(user_scale)
656 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
657 else
658 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
659 if(sys_recolor)
660 recolor_mouse(tmpbmp);
661 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
662 destroy_bitmap(tmpbmp);
663 }
664 else
665 {
666 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
667 }
668 }
669
670 //Handles converting the mouse sprite from the .dat file
671 27 void recolor_mouse(BITMAP* bmp)
672 {
673
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t x = 0; x < bmp->w; ++x)
674 {
675
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 432 times.
7344 for(int32_t y = 0; y < bmp->h; ++y)
676 {
677 6912 int32_t color = getpixel(bmp, x, y);
678
5/5
✓ Branch 0 taken 4698 times.
✓ Branch 1 taken 513 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 621 times.
✓ Branch 4 taken 486 times.
6912 switch(color)
679 {
680 case dvc(1):
681 513 color = jwin_pal[jcCURSORMISC];
682 513 break;
683 case dvc(2):
684 594 color = jwin_pal[jcCURSOROUTLINE];
685 594 break;
686 case dvc(3):
687 621 color = jwin_pal[jcCURSORLIGHT];
688 621 break;
689 case dvc(5):
690 486 color = jwin_pal[jcCURSORDARK];
691 486 break;
692 default:
693 4698 continue;
694 }
695 2214 putpixel(bmp, x, y, color);
696 2214 }
697 432 }
698 27 }
699 27 void load_mouse()
700 {
701 PALETTE pal;
702 27 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
703
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (!cursor_bitmap)
704 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
705
706 27 enter_sys_pal();
707 27 MouseSprite::set(-1);
708 27 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
709 27 int32_t sz = 16*scale;
710
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t j = 0; j < 1; ++j)
711 {
712 27 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
713
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(zcmouse[j])
714 destroy_bitmap(zcmouse[j]);
715 27 zcmouse[j] = create_bitmap_ex(8,sz,sz);
716 27 clear_bitmap(zcmouse[j]);
717 27 clear_bitmap(tmpbmp);
718 27 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
719 27 recolor_mouse(tmpbmp);
720
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(sz!=16)
721 27 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
722 else
723 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
724 27 destroy_bitmap(tmpbmp);
725 27 }
726
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!hw_palette) hw_palette = &RAMpal;
727 27 zc_set_palette(*hw_palette);
728
729 27 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
730 27 clear_bitmap(blankmouse);
731
732 27 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
733 27 MouseSprite::assign(ZCM_BLANK, blankmouse);
734 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
735
736 //Reload the mouse
737
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(system_mouse)
738 27 sys_mouse();
739 else game_mouse();
740
741 27 destroy_bitmap(blankmouse);
742 27 destroy_bitmap(cursor_bitmap);
743 27 exit_sys_pal();
744 27 }
745
746 // sets the video mode and initializes the palette and mouse sprite
747 266 bool game_vid_mode(int32_t mode,int32_t wait)
748 {
749
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 27 times.
266 if (is_headless())
750 239 return true;
751
752 extern int zq_screen_w, zq_screen_h;
753
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
754 {
755 return false;
756 }
757
758 27 scrx = (resx-320)>>1;
759 27 scry = (resy-240)>>1;
760
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
761 27 zcmouse[q] = NULL;
762 27 load_mouse();
763
764
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t i=240; i<256; i++)
765 432 RAMpal[i]=pal_gui[i];
766
767 27 zc_set_palette(RAMpal);
768 27 clear_to_color(screen,BLACK);
769
770 27 rest(wait);
771 27 return true;
772 266 }
773
774 275 void null_quest()
775 {
776 char qstdat_string[2048];
777 275 strcpy(qstdat_string, "modules/classic/default.qst");
778
779 #ifdef __EMSCRIPTEN__
780 // The quest template data file is not included because it's really big and isn't really needed
781 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
782 // which is much smaller.
783 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
784 #endif
785
786 275 byte skip_flags[4] = { 0 };
787
788 275 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
789 275 }
790
791 275 void init_NES_mode()
792 {
793 275 null_quest();
794 275 }
795
796 //----------------------------------------------------------------
797
798 qword trianglelines[16]=
799 {
800 0x0000000000000000ULL,
801 0xFD00000000000000ULL,
802 0xFDFD000000000000ULL,
803 0xFDFDFD0000000000ULL,
804 0xFDFDFDFD00000000ULL,
805 0xFDFDFDFDFD000000ULL,
806 0xFDFDFDFDFDFD0000ULL,
807 0xFDFDFDFDFDFDFD00ULL,
808 0xFDFDFDFDFDFDFDFDULL,
809 0x00FDFDFDFDFDFDFDULL,
810 0x0000FDFDFDFDFDFDULL,
811 0x000000FDFDFDFDFDULL,
812 0x00000000FDFDFDFDULL,
813 0x0000000000FDFDFDULL,
814 0x000000000000FDFDULL,
815 0x00000000000000FDULL,
816 };
817
818 word screen_triangles[28][32];
819 /*
820 qword triangles[4][16]= //[direction][value]
821 {
822 {
823 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
824 },
825 {
826 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
827 },
828 {
829 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
830 },
831 {
832 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
833 }
834 };
835 */
836
837
838 /*
839 byte triangles[4][16][8]= //[direction][value][line]
840 {
841 {
842 {
843 0, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 1, 0, 0, 0, 0, 0, 0, 0
847 },
848 {
849 2, 1, 0, 0, 0, 0, 0, 0
850 },
851 {
852 3, 2, 1, 0, 0, 0, 0, 0
853 },
854 {
855 4, 3, 2, 1, 0, 0, 0, 0
856 },
857 {
858 5, 4, 3, 2, 1, 0, 0, 0
859 },
860 {
861 6, 5, 4, 3, 2, 1, 0, 0
862 },
863 {
864 7, 6, 5, 4, 3, 2, 1, 0
865 },
866 {
867 8, 7, 6, 5, 4, 3, 2, 1
868 },
869 {
870 8, 8, 7, 6, 5, 4, 3, 2
871 },
872 {
873 8, 8, 8, 7, 6, 5, 4, 3
874 },
875 {
876 8, 8, 8, 8, 7, 6, 5, 4
877 },
878 {
879 8, 8, 8, 8, 8, 7, 6, 5
880 },
881 {
882 8, 8, 8, 8, 8, 8, 7, 6
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 7
886 },
887 {
888 8, 8, 8, 8, 8, 8, 8, 8
889 }
890 },
891 {
892 {
893 0, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 15, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 14, 15, 0, 0, 0, 0, 0, 0
900 },
901 {
902 13, 14, 15, 0, 0, 0, 0, 0
903 },
904 {
905 12, 13, 14, 15, 0, 0, 0, 0
906 },
907 {
908 11, 12, 13, 14, 15, 0, 0, 0
909 },
910 {
911 10, 11, 12, 13, 14, 15, 0, 0
912 },
913 {
914 9, 10, 11, 12, 13, 14, 15, 0
915 },
916 {
917 8, 9, 10, 11, 12, 13, 14, 15
918 },
919 {
920 8, 8, 9, 10, 11, 12, 13, 14
921 },
922 {
923 8, 8, 8, 9, 10, 11, 12, 13
924 },
925 {
926 8, 8, 8, 8, 9, 10, 11, 12
927 },
928 {
929 8, 8, 8, 8, 8, 9, 10, 11
930 },
931 {
932 8, 8, 8, 8, 8, 8, 9, 10
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 9
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 8
939 }
940 },
941 {
942 {
943 0, 0, 0, 0, 0, 0, 0, 0
944 },
945 {
946 0, 0, 0, 0, 0, 0, 0, 1
947 },
948 {
949 0, 0, 0, 0, 0, 0, 1, 2
950 },
951 {
952 0, 0, 0, 0, 0, 1, 2, 3
953 },
954 {
955 0, 0, 0, 0, 1, 2, 3, 4
956 },
957 {
958 0, 0, 0, 1, 2, 3, 4, 5
959 },
960 {
961 0, 0, 1, 2, 3, 4, 5, 6
962 },
963 {
964 0, 1, 2, 3, 4, 5, 6, 7
965 },
966 {
967 1, 2, 3, 4, 5, 6, 7, 8
968 },
969 {
970 2, 3, 4, 5, 6, 7, 8, 8
971 },
972 {
973 3, 4, 5, 6, 7, 8, 8, 8
974 },
975 {
976 4, 5, 6, 7, 8, 8, 8, 8
977 },
978 {
979 5, 6, 7, 8, 8, 8, 8, 8
980 },
981 {
982 6, 7, 8, 8, 8, 8, 8, 8
983 },
984 {
985 7, 8, 8, 8, 8, 8, 8, 8
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 8
989 }
990 },
991 {
992 {
993 0, 0, 0, 0, 0, 0, 0, 0
994 },
995 {
996 0, 0, 0, 0, 0, 0, 0, 15
997 },
998 {
999 0, 0, 0, 0, 0, 0, 15, 14
1000 },
1001 {
1002 0, 0, 0, 0, 0, 15, 14, 13
1003 },
1004 {
1005 0, 0, 0, 0, 15, 14, 13, 12
1006 },
1007 {
1008 0, 0, 0, 15, 14, 13, 12, 11
1009 },
1010 {
1011 0, 0, 15, 14, 13, 12, 11, 10
1012 },
1013 {
1014 0, 15, 14, 13, 12, 11, 10, 9
1015 },
1016 {
1017 15, 14, 13, 12, 11, 10, 9, 8
1018 },
1019 {
1020 14, 13, 12, 11, 10, 9, 8, 8
1021 },
1022 {
1023 13, 12, 11, 10, 9, 8, 8, 8
1024 },
1025 {
1026 12, 11, 10, 9, 8, 8, 8, 8
1027 },
1028 {
1029 11, 10, 9, 8, 8, 8, 8, 8
1030 },
1031 {
1032 10, 9, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 9, 8, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 8, 8, 8, 8, 8, 8, 8, 8
1039 }
1040 }
1041 };
1042 */
1043
1044
1045
1046 /*
1047 for (int32_t blockrow=0; blockrow<30; ++i)
1048 {
1049 for (int32_t linerow=0; linerow<8; ++i)
1050 {
1051 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1052 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1053 {
1054 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1055 ++triangleline;
1056 }
1057 }
1058 }
1059 */
1060
1061 // the ULL suffixes are to prevent this warning:
1062 // warning: integer constant is too large for "int32_t" type
1063
1064 qword triangles[4][16][8]= //[direction][value][line]
1065 {
1066 {
1067 {
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL
1076 },
1077 {
1078 0xFD00000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL
1086 },
1087 {
1088 0xFDFD000000000000ULL,
1089 0xFD00000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL
1096 },
1097 {
1098 0xFDFDFD0000000000ULL,
1099 0xFDFD000000000000ULL,
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFDFDFDFD00000000ULL,
1109 0xFDFDFD0000000000ULL,
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFDFDFDFD000000ULL,
1119 0xFDFDFDFD00000000ULL,
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFDFDFDFD0000ULL,
1129 0xFDFDFDFDFD000000ULL,
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFDFDFDFD00ULL,
1139 0xFDFDFDFDFDFD0000ULL,
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFD00ULL,
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL
1226 }
1227 },
1228 {
1229 {
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL
1238 },
1239 {
1240 0x00000000000000FDULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL
1248 },
1249 {
1250 0x000000000000FDFDULL,
1251 0x00000000000000FDULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL
1258 },
1259 {
1260 0x0000000000FDFDFDULL,
1261 0x000000000000FDFDULL,
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000FDFDFDFDULL,
1271 0x0000000000FDFDFDULL,
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000FDFDFDFDFDULL,
1281 0x00000000FDFDFDFDULL,
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000FDFDFDFDFDFDULL,
1291 0x000000FDFDFDFDFDULL,
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00FDFDFDFDFDFDFDULL,
1301 0x0000FDFDFDFDFDFDULL,
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0x00FDFDFDFDFDFDFDULL,
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL
1318 },
1319 {
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL
1328 },
1329 {
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL
1388 }
1389 },
1390 {
1391 {
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL
1400 },
1401 {
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL
1410 },
1411 {
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL
1420 },
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL
1470 },
1471 {
1472 0xFD00000000000000ULL,
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL
1480 },
1481 {
1482 0xFDFD000000000000ULL,
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL
1490 },
1491 {
1492 0xFDFDFD0000000000ULL,
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL
1500 },
1501 {
1502 0xFDFDFDFD00000000ULL,
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFDFDFDFD000000ULL,
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFDFDFDFD0000ULL,
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFDFDFDFD00ULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 }
1551 },
1552 {
1553 {
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL
1562 },
1563 {
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL
1572 },
1573 {
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL
1582 },
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL
1632 },
1633 {
1634 0x00000000000000FDULL,
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL
1642 },
1643 {
1644 0x000000000000FDFDULL,
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000FDFDFDULL,
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000FDFDFDFDULL,
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000FDFDFDFDFDULL,
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000FDFDFDFDFDFDULL,
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00FDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 }
1713 }
1714 };
1715
1716 int32_t black_opening_count=0;
1717 int32_t black_opening_x,black_opening_y;
1718 int32_t black_opening_shape;
1719
1720 3231 int32_t choose_opening_shape()
1721 {
1722 // First, count how many bits are set
1723 3231 int32_t numBits=0;
1724 int32_t bitCounter;
1725
1726
2/2
✓ Branch 0 taken 16155 times.
✓ Branch 1 taken 3231 times.
19386 for(int32_t i=0; i<bosMAX; i++)
1727 {
1728
2/2
✓ Branch 0 taken 12708 times.
✓ Branch 1 taken 3447 times.
16155 if(COOLSCROLL&(1<<i))
1729 3447 numBits++;
1730 16155 }
1731
1732 // Shouldn't happen...
1733
1/2
✓ Branch 0 taken 3231 times.
✗ Branch 1 not taken.
3231 if(numBits==0)
1734 return bosCIRCLE;
1735
1736 // Pick a bit
1737 3231 bitCounter=zc_rand()%numBits+1;
1738
1739
2/2
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 26 times.
4448 for(int32_t i=0; i<bosMAX; i++)
1740 {
1741 // If this bit is set, decrement the bit counter
1742
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 3361 times.
4422 if(COOLSCROLL&(1<<i))
1743 3361 bitCounter--;
1744
1745 // When the counter hits 0, return a value based on
1746 // which bit it stopped on.
1747 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1748
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 1217 times.
4422 if(bitCounter==0)
1749 3205 return i;
1750 1217 }
1751
1752 // Shouldn't be necessary, but the compiler might complain, at least
1753 26 return bosCIRCLE;
1754 3231 }
1755
1756 727 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1757 {
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1759
1760 727 int32_t w=256, h=224;
1761 727 int32_t blockrows=28, blockcolumns=32;
1762 727 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1763
1764
2/2
✓ Branch 0 taken 20356 times.
✓ Branch 1 taken 727 times.
21083 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1765 {
1766
2/2
✓ Branch 0 taken 651392 times.
✓ Branch 1 taken 20356 times.
671748 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1767 {
1768
2/2
✓ Branch 0 taken 269309 times.
✓ Branch 1 taken 382083 times.
651392 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1769 651392 }
1770 20356 }
1771
1772 727 black_opening_count = 66;
1773 727 black_opening_x = x;
1774 727 black_opening_y = y;
1775 727 lensclk = 0;
1776 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1777
1778
1779
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(black_opening_shape == bosFADEBLACK)
1780 {
1781 refreshTints();
1782 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1783 }
1784
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 4 times.
727 if(wait)
1785 {
1786 4 FFCore.warpScriptCheck();
1787
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 264 times.
268 for(int32_t i=0; i<66; i++)
1788 {
1789 264 draw_screen(tmpscr);
1790 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1791 264 advanceframe(true);
1792
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Quit)
1794 {
1795 break;
1796 }
1797 264 }
1798 4 }
1799 727 }
1800
1801 2504 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1802 {
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504 times.
2504 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1804
1805 2504 int32_t w=256, h=224;
1806 2504 int32_t blockrows=28, blockcolumns=32;
1807 2504 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1808
1809
2/2
✓ Branch 0 taken 70112 times.
✓ Branch 1 taken 2504 times.
72616 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1810 {
1811
2/2
✓ Branch 0 taken 2243584 times.
✓ Branch 1 taken 70112 times.
2313696 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1812 {
1813
2/2
✓ Branch 0 taken 1105155 times.
✓ Branch 1 taken 1138429 times.
2243584 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1814 2243584 }
1815 70112 }
1816
1817 2504 black_opening_count = -66;
1818 2504 black_opening_x = x;
1819 2504 black_opening_y = y;
1820 2504 lensclk = 0;
1821
1/2
✓ Branch 0 taken 2504 times.
✗ Branch 1 not taken.
2504 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 2138 times.
2504 if(wait)
1827 {
1828 2138 FFCore.warpScriptCheck();
1829
2/2
✓ Branch 0 taken 2137 times.
✓ Branch 1 taken 141111 times.
143248 for(int32_t i=0; i<66; i++)
1830 {
1831 141111 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1833 141111 advanceframe(true);
1834
1835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 141110 times.
141111 if(Quit)
1836 {
1837 1 break;
1838 }
1839 141110 }
1840 2138 }
1841 2504 }
1842
1843 212600 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1844 {
1845 212600 clear_to_color(tmp_scr,BLACK);
1846 212600 int32_t w=256, h=224;
1847
1848
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9636 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 20262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 182042 times.
212600 switch(black_opening_shape)
1849 {
1850 case bosOVAL:
1851 {
1852 9636 double new_w=(w/2)+abs(w/2-x);
1853 9636 double new_h=(h/2)+abs(h/2-y);
1854 9636 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1855 9636 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1856 9636 break;
1857 }
1858
1859 case bosTRIANGLE:
1860 {
1861 660 double new_w=(w/2)+abs(w/2-x);
1862 660 double new_h=(h/2)+abs(h/2-y);
1863 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1864 660 double P2= (PI/2);
1865 660 double P23=(2*PI/3);
1866 660 double P43=(4*PI/3);
1867 660 double Pa= (-4*PI*a/(3*max_a));
1868 660 double angle=P2+Pa;
1869 660 double a0=angle;
1870 660 double a2=angle+P23;
1871 660 double a4=angle+P43;
1872 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1873 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1874 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1875 0);
1876 660 break;
1877 }
1878
1879 case bosSMAS:
1880 {
1881
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 13068 times.
20262 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1882
1883
2/2
✓ Branch 0 taken 567336 times.
✓ Branch 1 taken 20262 times.
587598 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1884 {
1885
2/2
✓ Branch 0 taken 4538688 times.
✓ Branch 1 taken 567336 times.
5106024 for(int32_t linerow=0; linerow<8; ++linerow)
1886 {
1887 4538688 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1888
1889
2/2
✓ Branch 0 taken 145238016 times.
✓ Branch 1 taken 4538688 times.
149776704 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1890 {
1891 435714048 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1892
6/6
✓ Branch 0 taken 104912184 times.
✓ Branch 1 taken 40325832 times.
✓ Branch 2 taken 95821040 times.
✓ Branch 3 taken 49416976 times.
✓ Branch 4 taken 55495208 times.
✓ Branch 5 taken 40325832 times.
145238016 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1893 145238016 [linerow];
1894 145238016 ++triangleline;
1895
1896
2/2
✓ Branch 0 taken 127083264 times.
✓ Branch 1 taken 18154752 times.
145238016 if(linerow==0)
1897 {
1898 18154752 }
1899 145238016 }
1900 4538688 }
1901 567336 }
1902
1903 20262 break;
1904 }
1905
1906 case bosFADEBLACK:
1907 {
1908 if(black_opening_count<0)
1909 {
1910 black_fade(zc_min(-black_opening_count,63));
1911 }
1912 else if(black_opening_count>0)
1913 {
1914 black_fade(63-zc_max(black_opening_count-3,0));
1915 }
1916 else black_fade(0);
1917 return; //no blitting from tmp_scr!
1918 }
1919
1920 182042 case bosCIRCLE:
1921 default:
1922 {
1923 182042 double new_w=(w/2)+abs(w/2-x);
1924 182042 double new_h=(h/2)+abs(h/2-y);
1925 182042 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1926 //circlefill(tmp_scr,x,y,a<<3,0);
1927 182042 circlefill(tmp_scr,x,y,r,0);
1928 182042 break;
1929 }
1930 }
1931
1932 212600 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1933 212600 }
1934
1935
1936 void black_fade(int32_t fadeamnt)
1937 {
1938 for(int32_t i=0; i < 0xEF; i++)
1939 {
1940 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1941 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1942 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1943 }
1944
1945 refreshpal = true;
1946 }
1947
1948 //----------------------------------------------------------------
1949
1950 200284142 bool item_disabled(int32_t item) //is this item disabled?
1951 {
1952
2/2
✓ Branch 0 taken 14429064 times.
✓ Branch 1 taken 185855078 times.
200284142 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1953 }
1954
1955 15463033 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1956 {
1957
2/2
✓ Branch 0 taken 188072 times.
✓ Branch 1 taken 15274961 times.
15463033 if(current_item(item_type, true) >=item)
1958 {
1959 188072 return true;
1960 }
1961
1962 15274961 return false;
1963 15463033 }
1964
1965 48082128 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1966 {
1967
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4372115 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4902235 times.
✓ Branch 6 taken 28719324 times.
✓ Branch 7 taken 9894000 times.
✓ Branch 8 taken 194454 times.
48082128 switch(item_type)
1968 {
1969 case itype_bomb:
1970 case itype_sbomb:
1971 {
1972 int32_t itemid = getItemID(itemsbuf, item_type, it);
1973
1974 if(itemid == -1)
1975 return false;
1976
1977 return (game->get_item(itemid));
1978 }
1979
1980 case itype_clock:
1981 {
1982 4372115 int32_t itemid = getItemID(itemsbuf, item_type, it);
1983
1984
2/4
✓ Branch 0 taken 4372115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4372115 times.
✗ Branch 3 not taken.
4372115 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1985 return (game->get_item(itemid));
1986 4372115 return Hero.getClock()?1:0;
1987 }
1988
1989 case itype_key:
1990 return (game->get_keys()>0);
1991
1992 case itype_magiccontainer:
1993 return (game->get_maxmagic()>=game->get_mp_per_block());
1994
1995 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1996 {
1997
2/3
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4581019 times.
4902235 switch(it)
1998 {
1999 case -2:
2000 {
2001 for(int32_t i=0; i<MAXLEVELS; i++)
2002 {
2003 if(game->lvlitems[i]&liTRIFORCE)
2004 {
2005 return true;
2006 }
2007 }
2008
2009 return false;
2010 }
2011
2012 case -1:
2013 4581019 return (game->lvlitems[dlevel]&liTRIFORCE);
2014
2015 default:
2016
2/4
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321216 times.
321216 if(it>=0&&it<MAXLEVELS)
2017 {
2018 321216 return (game->lvlitems[it]&liTRIFORCE);
2019 }
2020
2021 break;
2022 }
2023
2024 return 0;
2025 }
2026
2027 case itype_map: //it: -2=any, -1=current level, other=that level
2028 {
2029
2/3
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28178922 times.
28719324 switch(it)
2030 {
2031 case -2:
2032 {
2033 for(int32_t i=0; i<MAXLEVELS; i++)
2034 {
2035 if(game->lvlitems[i]&liMAP)
2036 {
2037 return true;
2038 }
2039 }
2040
2041 return false;
2042 }
2043
2044 case -1:
2045 28178922 return (game->lvlitems[dlevel]&liMAP)!=0;
2046
2047 default:
2048
2/4
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540402 times.
540402 if(it>=0&&it<MAXLEVELS)
2049 {
2050 540402 return (game->lvlitems[it]&liMAP)!=0;
2051 }
2052
2053 break;
2054 }
2055
2056 return 0;
2057 }
2058
2059 case itype_compass: //it: -2=any, -1=current level, other=that level
2060 {
2061
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9894000 times.
9894000 switch(it)
2062 {
2063 case -2:
2064 {
2065 for(int32_t i=0; i<MAXLEVELS; i++)
2066 {
2067 if(game->lvlitems[i]&liCOMPASS)
2068 {
2069 return true;
2070 }
2071 }
2072
2073 return false;
2074 }
2075
2076 case -1:
2077 9894000 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2078
2079 default:
2080 if(it>=0&&it<MAXLEVELS)
2081 {
2082 return (game->lvlitems[it]&liCOMPASS)!=0;
2083 }
2084
2085 break;
2086 }
2087 return 0;
2088 }
2089
2090 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 194454 times.
194454 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liBOSSKEY)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 194454 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2109
2110 default:
2111 if(it>=0&&it<MAXLEVELS)
2112 {
2113 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2114 }
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 default:
2121 //it=(1<<(it-1));
2122 /*if (item_type>=itype_max)
2123 {
2124 enter_sys_pal();
2125 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2126 exit_sys_pal();
2127
2128 return false;
2129 }*/
2130 int32_t itemid = getItemID(itemsbuf, item_type, it);
2131
2132 if(itemid == -1)
2133 return false;
2134
2135 return game->get_item(itemid);
2136 }
2137 48082128 }
2138
2139 149275650 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
2140 {
2141
9/9
✓ Branch 0 taken 4372115 times.
✓ Branch 1 taken 114298730 times.
✓ Branch 2 taken 4372115 times.
✓ Branch 3 taken 4372115 times.
✓ Branch 4 taken 4372115 times.
✓ Branch 5 taken 4372115 times.
✓ Branch 6 taken 4372115 times.
✓ Branch 7 taken 4372115 times.
✓ Branch 8 taken 4372115 times.
149275650 switch(item_type)
2142 {
2143 case itype_clock:
2144 {
2145 4372115 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2146
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4372115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4372115 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2148 return itemsbuf[maxid].fam_type;
2149
2150 4372115 return has_item(itype_clock,1) ? 1 : 0;
2151 }
2152
2153 case itype_key:
2154 4372115 return game->get_keys();
2155
2156 case itype_lkey:
2157 4372115 return game->lvlkeys[get_dlevel()];
2158
2159 case itype_magiccontainer:
2160 4372115 return game->get_maxmagic()/game->get_mp_per_block();
2161
2162 case itype_triforcepiece:
2163 {
2164 4372115 int count=0;
2165
2166
2/2
✓ Branch 0 taken 2238522880 times.
✓ Branch 1 taken 4372115 times.
2242894995 for(int i=0; i<MAXLEVELS; i++)
2167 {
2168 2238522880 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2169 2238522880 }
2170
2171 4372115 return count;
2172 }
2173
2174 case itype_map:
2175 {
2176 4372115 int count=0;
2177
2178
2/2
✓ Branch 0 taken 2238522880 times.
✓ Branch 1 taken 4372115 times.
2242894995 for(int i=0; i<MAXLEVELS; i++)
2179 {
2180 2238522880 count+=(game->lvlitems[i]&liMAP)?1:0;
2181 2238522880 }
2182
2183 4372115 return count;
2184 }
2185
2186 case itype_compass:
2187 {
2188 4372115 int count=0;
2189
2190
2/2
✓ Branch 0 taken 2238522880 times.
✓ Branch 1 taken 4372115 times.
2242894995 for(int i=0; i<MAXLEVELS; i++)
2191 {
2192 2238522880 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2193 2238522880 }
2194
2195 4372115 return count;
2196 }
2197
2198 case itype_bosskey:
2199 {
2200 4372115 int count=0;
2201
2202
2/2
✓ Branch 0 taken 2238522880 times.
✓ Branch 1 taken 4372115 times.
2242894995 for(int i=0; i<MAXLEVELS; i++)
2203 {
2204 2238522880 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2205 2238522880 }
2206
2207 4372115 return count;
2208 }
2209
2210 default:
2211 114298730 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2212
2213
2/2
✓ Branch 0 taken 33025825 times.
✓ Branch 1 taken 81272905 times.
114298730 if(maxid == -1)
2214 81272905 return 0;
2215
2216 33025825 return itemsbuf[maxid].fam_type;
2217 }
2218 149275650 }
2219
2220 355 std::map<int32_t, int32_t> itemcache;
2221 355 std::map<int32_t, int32_t> itemcache_cost;
2222
2223 void removeFromItemCache(int32_t itemclass)
2224 {
2225 itemcache.erase(itemclass);
2226 itemcache_cost.erase(itemclass);
2227 cache_tile_mod_clear();
2228 }
2229
2230 12390119 void flushItemCache(bool justcost)
2231 {
2232 12390119 itemcache_cost.clear();
2233
2/2
✓ Branch 0 taken 12323668 times.
✓ Branch 1 taken 66451 times.
12390119 if(!justcost)
2234 66451 itemcache.clear();
2235
2/2
✓ Branch 0 taken 5826470 times.
✓ Branch 1 taken 6497198 times.
12323668 else if(replay_version_check(0,19))
2236 5826470 return;
2237
2238 6563649 cache_tile_mod_clear();
2239
2240 //also fix the active subscreen if items were deleted -DD
2241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6563649 times.
6563649 if(game != NULL)
2242 {
2243 6563649 verifyBothWeapons();
2244 6563649 refresh_subscr_items();
2245 6563649 }
2246 12390119 }
2247
2248 // This is used often, so it should be as direct as possible.
2249 2947553778 int _c_item_id_internal(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2250 {
2251 2947553778 bool use_cost_cache = replay_version_check(19);
2252
2/2
✓ Branch 0 taken 2827579721 times.
✓ Branch 1 taken 119974057 times.
2947553778 if(jinx_check)
2253 {
2254
4/4
✓ Branch 0 taken 86928973 times.
✓ Branch 1 taken 33045084 times.
✓ Branch 2 taken 11013560 times.
✓ Branch 3 taken 75915413 times.
119974057 if(!(HeroSwordClk() || HeroItemClk()))
2255 75915413 jinx_check = false; //not jinxed
2256 119974057 }
2257
4/4
✓ Branch 0 taken 103098 times.
✓ Branch 1 taken 2947450680 times.
✓ Branch 2 taken 1853 times.
✓ Branch 3 taken 101245 times.
2947553778 if(!Hero.BunnyClock() || itemtype == itype_pearl) // bunny_check does not apply
2258 2947452533 check_bunny = false;
2259
2/2
✓ Branch 0 taken 2891638012 times.
✓ Branch 1 taken 55915766 times.
2947553778 if(itemtype == itype_ring) checkmagic = true;
2260
4/4
✓ Branch 0 taken 2903495134 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 274389087 times.
✓ Branch 3 taken 23761870 times.
3245704735 if (!jinx_check && !check_bunny
2261
4/4
✓ Branch 0 taken 2903415887 times.
✓ Branch 1 taken 79247 times.
✓ Branch 2 taken 298150957 times.
✓ Branch 3 taken 2605264930 times.
2903495134 && (use_cost_cache || itemtype != itype_ring))
2262 {
2263
4/4
✓ Branch 0 taken 537948604 times.
✓ Branch 1 taken 2341705413 times.
✓ Branch 2 taken 232608595 times.
✓ Branch 3 taken 305340009 times.
2879654017 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2264 2879654017 auto res = cache.find(itemtype);
2265
2266
2/2
✓ Branch 0 taken 2735536668 times.
✓ Branch 1 taken 144117349 times.
2879654017 if(res != cache.end())
2267 2735536668 return res->second;
2268 144117349 }
2269
2270 212017110 int result = -1;
2271 212017110 int highestlevel = -1;
2272
2273
2/2
✓ Branch 0 taken 54276380160 times.
✓ Branch 1 taken 212017110 times.
54488397270 for(int i=0; i<MAXITEMS; i++)
2274 {
2275
6/6
✓ Branch 0 taken 5954495275 times.
✓ Branch 1 taken 48321884885 times.
✓ Branch 2 taken 97443225 times.
✓ Branch 3 taken 5857052050 times.
✓ Branch 4 taken 82048 times.
✓ Branch 5 taken 97361177 times.
54276380160 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2276 {
2277
4/4
✓ Branch 0 taken 92602574 times.
✓ Branch 1 taken 4758603 times.
✓ Branch 2 taken 2425909 times.
✓ Branch 3 taken 90176665 times.
97361177 if(checkmagic && itemtype != itype_magicring)
2278
2/2
✓ Branch 0 taken 90176048 times.
✓ Branch 1 taken 617 times.
90176665 if(!checkmagiccost(i))
2279 617 continue;
2280
6/6
✓ Branch 0 taken 88421400 times.
✓ Branch 1 taken 8939160 times.
✓ Branch 2 taken 1253626 times.
✓ Branch 3 taken 7685534 times.
✓ Branch 4 taken 5007993 times.
✓ Branch 5 taken 3931167 times.
97360560 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3931167 times.
3931167 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2282 3931167 continue;
2283
3/4
✓ Branch 0 taken 86055 times.
✓ Branch 1 taken 93343338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86055 times.
93429393 if(check_bunny && !checkbunny(i))
2284 86055 continue;
2285
2286
2/2
✓ Branch 0 taken 9055025 times.
✓ Branch 1 taken 84288313 times.
93343338 if(itemsbuf[i].fam_type >= highestlevel)
2287 {
2288 84288313 highestlevel = itemsbuf[i].fam_type;
2289 84288313 result=i;
2290 84288313 }
2291 93343338 }
2292 54272362321 }
2293
2294
4/4
✓ Branch 0 taken 167958466 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 79247 times.
✓ Branch 3 taken 167879219 times.
212017110 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2295 {
2296
2/2
✓ Branch 0 taken 128117440 times.
✓ Branch 1 taken 39761779 times.
167879219 if (use_cost_cache)
2297 {
2298
2/2
✓ Branch 0 taken 112362707 times.
✓ Branch 1 taken 15754733 times.
128117440 if (!checkmagic)
2299 15754733 itemcache[itemtype] = result;
2300
6/6
✓ Branch 0 taken 15754733 times.
✓ Branch 1 taken 112362707 times.
✓ Branch 2 taken 659733 times.
✓ Branch 3 taken 15095000 times.
✓ Branch 4 taken 647104 times.
✓ Branch 5 taken 12629 times.
128117440 if (checkmagic || result < 0 || checkmagiccost(result))
2301 128104811 itemcache_cost[itemtype] = result;
2302 128117440 }
2303 else
2304 {
2305 39761779 itemcache[itemtype] = result;
2306 }
2307 167879219 }
2308 212017110 return result;
2309 2947553778 }
2310
2311 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2312 2904590259 int current_item_id(int itype, bool checkmagic, bool jinx_check, bool check_bunny)
2313 {
2314
2/4
✓ Branch 0 taken 2904590259 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2904590259 times.
2904590259 if(itype < 0 || itype >= itype_max) return -1;
2315
1/2
✓ Branch 0 taken 2904590259 times.
✗ Branch 1 not taken.
2904590259 if(game->OverrideItems[itype] > -2)
2316 {
2317 auto ovid = game->OverrideItems[itype];
2318 if(ovid < 0 || ovid >= MAXITEMS)
2319 return -1;
2320 if(itemsbuf[ovid].family == itype)
2321 {
2322 if(itype == itype_magicring)
2323 checkmagic = false;
2324 else if(itype == itype_ring)
2325 checkmagic = true;
2326
2327 if(checkmagic && !checkmagiccost(ovid))
2328 return -1;
2329 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2330 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2331 return -1;
2332 return ovid;
2333 }
2334 }
2335 2904590259 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2336
2/2
✓ Branch 0 taken 77010538 times.
✓ Branch 1 taken 2827579721 times.
2904590259 if(!jinx_check) //If not already a jinx-immune-only check...
2337 {
2338 //And the player IS jinxed...
2339
4/4
✓ Branch 0 taken 2795374138 times.
✓ Branch 1 taken 32205583 times.
✓ Branch 2 taken 10757936 times.
✓ Branch 3 taken 2784616202 times.
2827579721 if(HeroSwordClk() || HeroItemClk())
2340 {
2341 //Then do a jinx-immune-only check here
2342 42963519 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2343 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2344 //Should NOT need a compat rule, as this should always return -1 in old quests.
2345
2/2
✓ Branch 0 taken 3272877 times.
✓ Branch 1 taken 39690642 times.
42963519 if(ret2 > -1) return ret2;
2346 39690642 }
2347 2824306844 }
2348 2901317382 return ret;
2349 2904590259 }
2350
2351 46391443 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2352 {
2353 46391443 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
2354
2/2
✓ Branch 0 taken 26847051 times.
✓ Branch 1 taken 19544392 times.
46391443 return (result<0) ? 0 : itemsbuf[result].power;
2355 }
2356
2357 26 int32_t heart_container_id()
2358 {
2359
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 for(int32_t i=0; i<MAXITEMS; i++)
2360 {
2361
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 728 times.
754 if(itemsbuf[i].family == itype_heartcontainer)
2362 {
2363 26 return i;
2364 }
2365 728 }
2366 return -1;
2367 26 }
2368
2369 struct tilemod_cache_state_t
2370 {
2371
6/6
✓ Branch 0 taken 4371760 times.
✓ Branch 1 taken 8416073 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8416071 times.
✓ Branch 4 taken 353 times.
✓ Branch 5 taken 8415718 times.
21203906 bool operator==(const tilemod_cache_state_t&) const = default;
2372
2373 bool valid;
2374 bool bunny_clock;
2375 bool superman;
2376 int shield;
2377 };
2378 tilemod_cache_state_t tilemod_cache_state;
2379 int32_t tilemod_cache_value;
2380
2381 6565088 void cache_tile_mod_clear()
2382 {
2383 6565088 tilemod_cache_state = {false};
2384 6565088 }
2385
2386 12787833 int32_t item_tile_mod()
2387 {
2388 51151332 tilemod_cache_state_t state = {
2389 .valid = true,
2390 12787833 .bunny_clock = Hero.BunnyClock() != 0,
2391 12787833 .superman = Hero.superman,
2392 12787833 .shield = Hero.active_shield_id,
2393 };
2394
2/2
✓ Branch 0 taken 8415718 times.
✓ Branch 1 taken 4372115 times.
12787833 if (tilemod_cache_state == state)
2395 8415718 return tilemod_cache_value;
2396
2397 4372115 int32_t tile=0;
2398 4372115 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2399
4/4
✓ Branch 0 taken 3958878 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 3039599 times.
✓ Branch 3 taken 919279 times.
4372115 if(check_bombcost || game->get_bombs())
2400 {
2401 3452836 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2402
3/4
✓ Branch 0 taken 3393363 times.
✓ Branch 1 taken 59473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3393363 times.
3452836 if(itemid > -1 && checkbunny(itemid))
2403 3393363 tile+=itemsbuf[itemid].ltm;
2404 3452836 }
2405
2406
4/4
✓ Branch 0 taken 3958878 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 928295 times.
✓ Branch 3 taken 3030583 times.
4372115 if(check_bombcost || game->get_sbombs())
2407 {
2408 1341532 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2409
3/4
✓ Branch 0 taken 928054 times.
✓ Branch 1 taken 413478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 928054 times.
1341532 if(itemid > -1 && checkbunny(itemid))
2410 928054 tile+=itemsbuf[itemid].ltm;
2411 1341532 }
2412
2413
2/2
✓ Branch 0 taken 4367512 times.
✓ Branch 1 taken 4603 times.
4372115 if(current_item(itype_clock))
2414 {
2415 4603 int32_t itemid =
2416
2/2
✓ Branch 0 taken 4594 times.
✓ Branch 1 taken 9 times.
4603 get_qr(qr_HARDCODED_LITEM_LTMS)
2417 ? iClock
2418 9 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2419
2/4
✓ Branch 0 taken 4603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4603 times.
4603 if(itemid > -1 && checkbunny(itemid))
2420 4603 tile+=itemsbuf[itemid].ltm;
2421 4603 }
2422
2423
2/2
✓ Branch 0 taken 3763474 times.
✓ Branch 1 taken 608641 times.
4372115 if(current_item(itype_key))
2424 {
2425 608641 int32_t itemid =
2426
1/2
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
608641 get_qr(qr_HARDCODED_LITEM_LTMS)
2427 ? iKey
2428 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2429
2/4
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 608641 times.
608641 if(itemid > -1 && checkbunny(itemid))
2430 608641 tile+=itemsbuf[itemid].ltm;
2431 608641 }
2432
2433
2/2
✓ Branch 0 taken 3871255 times.
✓ Branch 1 taken 500860 times.
4372115 if(current_item(itype_lkey))
2434 {
2435 500860 int32_t itemid =
2436
2/2
✓ Branch 0 taken 414146 times.
✓ Branch 1 taken 86714 times.
500860 get_qr(qr_HARDCODED_LITEM_LTMS)
2437 ? iLevelKey
2438 86714 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2439
2/4
✓ Branch 0 taken 500860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500860 times.
500860 if(itemid > -1 && checkbunny(itemid))
2440 500860 tile+=itemsbuf[itemid].ltm;
2441 500860 }
2442
2443
2/2
✓ Branch 0 taken 1537646 times.
✓ Branch 1 taken 2834469 times.
4372115 if(current_item(itype_map))
2444 {
2445 2834469 int32_t itemid =
2446
2/2
✓ Branch 0 taken 2823835 times.
✓ Branch 1 taken 10634 times.
2834469 get_qr(qr_HARDCODED_LITEM_LTMS)
2447 ? iMap
2448 10634 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2449
2/4
✓ Branch 0 taken 2834469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2834469 times.
2834469 if(itemid > -1 && checkbunny(itemid))
2450 2834469 tile+=itemsbuf[itemid].ltm;
2451 2834469 }
2452
2453
2/2
✓ Branch 0 taken 2060125 times.
✓ Branch 1 taken 2311990 times.
4372115 if(current_item(itype_compass))
2454 {
2455 2311990 int32_t itemid =
2456
2/2
✓ Branch 0 taken 2295942 times.
✓ Branch 1 taken 16048 times.
2311990 get_qr(qr_HARDCODED_LITEM_LTMS)
2457 ? iCompass
2458 16048 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2459
2/4
✓ Branch 0 taken 2311990 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2311990 times.
2311990 if(itemid > -1 && checkbunny(itemid))
2460 2311990 tile+=itemsbuf[itemid].ltm;
2461 2311990 }
2462
2463
2/2
✓ Branch 0 taken 1285699 times.
✓ Branch 1 taken 3086416 times.
4372115 if(current_item(itype_bosskey))
2464 {
2465 3086416 int32_t itemid =
2466
2/2
✓ Branch 0 taken 2993139 times.
✓ Branch 1 taken 93277 times.
3086416 get_qr(qr_HARDCODED_LITEM_LTMS)
2467 ? iBossKey
2468 93277 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2469
2/4
✓ Branch 0 taken 3086416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3086416 times.
3086416 if(itemid > -1 && checkbunny(itemid))
2470 3086416 tile+=itemsbuf[itemid].ltm;
2471 3086416 }
2472
2473
2/2
✓ Branch 0 taken 48263 times.
✓ Branch 1 taken 4323852 times.
4372115 if(current_item(itype_magiccontainer))
2474 {
2475 4323852 int32_t itemid =
2476
2/2
✓ Branch 0 taken 3893053 times.
✓ Branch 1 taken 430799 times.
4323852 get_qr(qr_HARDCODED_LITEM_LTMS)
2477 ? iMagicC
2478 430799 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2479
3/4
✓ Branch 0 taken 4323852 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 4323835 times.
4323852 if(itemid > -1 && checkbunny(itemid))
2480 4323835 tile+=itemsbuf[itemid].ltm;
2481 4323852 }
2482
2483
2/2
✓ Branch 0 taken 1302928 times.
✓ Branch 1 taken 3069187 times.
4372115 if(current_item(itype_triforcepiece))
2484 {
2485 3069187 int32_t itemid =
2486
1/2
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
3069187 get_qr(qr_HARDCODED_LITEM_LTMS)
2487 ? iTriforce
2488 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2489
2/4
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3069187 times.
3069187 if(itemid > -1 && checkbunny(itemid))
2490 3069187 tile+=itemsbuf[itemid].ltm;
2491 3069187 }
2492
2493
2/2
✓ Branch 0 taken 2238522880 times.
✓ Branch 1 taken 4372115 times.
2242894995 for(int32_t i=0; i<itype_max; i++)
2494 {
2495
2/2
✓ Branch 0 taken 2017846272 times.
✓ Branch 1 taken 220676608 times.
2238522880 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2496 {
2497
2/2
✓ Branch 0 taken 4310090 times.
✓ Branch 1 taken 216366518 times.
220676608 switch(i)
2498 {
2499 case itype_bomb:
2500 case itype_sbomb:
2501 case itype_clock:
2502 case itype_key:
2503 case itype_lkey:
2504 case itype_map:
2505 case itype_compass:
2506 case itype_bosskey:
2507 case itype_magiccontainer:
2508 case itype_triforcepiece:
2509 4310090 continue; //already handled
2510 }
2511 216366518 }
2512 2234212790 int32_t itemid = current_item_id(i,false);
2513
2/2
✓ Branch 0 taken 2229840675 times.
✓ Branch 1 taken 4372115 times.
2234212790 if(i == itype_shield)
2514 4372115 itemid = getCurrentShield(false);
2515
2516
4/4
✓ Branch 0 taken 114055164 times.
✓ Branch 1 taken 2120157626 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 114055163 times.
2234212790 if(itemid < 0 || !checkbunny(itemid))
2517 2120157627 continue;
2518
2519 114055163 itemdata const& itm = itemsbuf[itemid];
2520
2521
2/2
✓ Branch 0 taken 110392540 times.
✓ Branch 1 taken 3662623 times.
114055163 switch(itm.family)
2522 {
2523 case itype_shield:
2524
1/2
✓ Branch 0 taken 3662623 times.
✗ Branch 1 not taken.
3662623 if(itm.flags & ITEM_FLAG9) //active shield
2525 {
2526 if(!usingActiveShield(itemid))
2527 {
2528 tile+=itm.misc6; //'Inactive PTM'
2529 continue;
2530 }
2531 }
2532 3662623 break;
2533 }
2534
2535 114055163 tile+=itm.ltm;
2536 114055163 }
2537
2538 4372115 tilemod_cache_value = tile;
2539 4372115 tilemod_cache_state = state;
2540 4372115 return tile;
2541 12787833 }
2542
2543 12787833 int32_t bunny_tile_mod()
2544 {
2545
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 12785963 times.
12787833 if(Hero.BunnyClock())
2546 {
2547 1870 return game->get_bunny_ltm();
2548 }
2549 12785963 return 0;
2550 12787833 }
2551
2552 // Hints are drawn on a separate layer to combo reveals.
2553 20010 void draw_lens_under(BITMAP *dest, bool layer)
2554 {
2555 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2556 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2557 //Lens flag 3: Don't show armos/chest/dive items
2558 //Lens flag 4: Show Raft Paths
2559 //Lens flag 5: Show Invisible Enemies
2560
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 19554 times.
✓ Branch 2 taken 9777 times.
✓ Branch 3 taken 9777 times.
20010 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2561
2562 20010 int32_t strike_hint_table[11]=
2563 {
2564 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2565 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2566 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2567 };
2568
2569 // int32_t page = tmpscr->cpage;
2570 {
2571 20010 int32_t blink_rate=flash_reduction_enabled()?6:1;
2572 // int32_t temptimer=0;
2573 20010 int32_t tempitem, tempweapon=0;
2574 20010 strike_hint=strike_hint_table[strike_hint_counter];
2575
2576
2/2
✓ Branch 0 taken 19412 times.
✓ Branch 1 taken 598 times.
20010 if(strike_hint_timer>32)
2577 {
2578 598 strike_hint_timer=0;
2579 598 strike_hint_counter=((strike_hint_counter+1)%11);
2580 598 }
2581
2582 20010 ++strike_hint_timer;
2583
2584
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 20010 times.
3541770 for(int32_t i=0; i<176; i++)
2585 {
2586 3521760 int32_t x = (i & 15) << 4;
2587 3521760 int32_t y = (i & 0xF0) + playing_field_offset;
2588 3521760 int32_t tempitemx=-16, tempitemy=-16;
2589 3521760 int32_t tempweaponx=-16, tempweapony=-16;
2590
2591
2/2
✓ Branch 0 taken 7043520 times.
✓ Branch 1 taken 3521760 times.
10565280 for(int32_t iter=0; iter<2; ++iter)
2592 {
2593 7043520 int32_t checkflag=0;
2594
2595
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 3521760 times.
7043520 if(iter==0)
2596 {
2597 3521760 checkflag=combobuf[tmpscr->data[i]].flag;
2598 3521760 }
2599 else
2600 {
2601 3521760 checkflag=tmpscr->sflag[i];
2602 }
2603
2604
2/2
✓ Branch 0 taken 7042422 times.
✓ Branch 1 taken 1098 times.
7043520 if(checkflag==mfSTRIKE)
2605 {
2606
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2607 {
2608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2609 906 }
2610 else
2611 {
2612 192 checkflag = strike_hint;
2613 }
2614 1098 }
2615
2616
21/36
✓ Branch 0 taken 6894870 times.
✓ Branch 1 taken 3258 times.
✓ Branch 2 taken 108898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2602 times.
✓ Branch 5 taken 28750 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 93 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 138 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
7043520 switch(checkflag)
2617 {
2618 case 0:
2619 case mfZELDA:
2620 case mfPUSHED:
2621 case mfENEMY0:
2622 case mfENEMY1:
2623 case mfENEMY2:
2624 case mfENEMY3:
2625 case mfENEMY4:
2626 case mfENEMY5:
2627 case mfENEMY6:
2628 case mfENEMY7:
2629 case mfENEMY8:
2630 case mfENEMY9:
2631 case mfSINGLE:
2632 case mfSINGLE16:
2633 case mfNOENEMY:
2634 case mfTRAP_H:
2635 case mfTRAP_V:
2636 case mfTRAP_4:
2637 case mfTRAP_LR:
2638 case mfTRAP_UD:
2639 case mfNOGROUNDENEMY:
2640 case mfNOBLOCKS:
2641 case mfSCRIPT1:
2642 case mfSCRIPT2:
2643 case mfSCRIPT3:
2644 case mfSCRIPT4:
2645 case mfSCRIPT5:
2646 case mfSCRIPT6:
2647 case mfSCRIPT7:
2648 case mfSCRIPT8:
2649 case mfSCRIPT9:
2650 case mfSCRIPT10:
2651 case mfSCRIPT11:
2652 case mfSCRIPT12:
2653 case mfSCRIPT13:
2654 case mfSCRIPT14:
2655 case mfSCRIPT15:
2656 case mfSCRIPT16:
2657 case mfSCRIPT17:
2658 case mfSCRIPT18:
2659 case mfSCRIPT19:
2660 case mfSCRIPT20:
2661 case mfPITHOLE:
2662 case mfPITFALLFLOOR:
2663 case mfLAVA:
2664 case mfICE:
2665 case mfICEDAMAGE:
2666 case mfDAMAGE1:
2667 case mfDAMAGE2:
2668 case mfDAMAGE4:
2669 case mfDAMAGE8:
2670 case mfDAMAGE16:
2671 case mfDAMAGE32:
2672 case mfFREEZEALL:
2673 case mfFREZEALLANSFFCS:
2674 case mfFREEZEFFCSOLY:
2675 case mfSCRITPTW1TRIG:
2676 case mfSCRITPTW2TRIG:
2677 case mfSCRITPTW3TRIG:
2678 case mfSCRITPTW4TRIG:
2679 case mfSCRITPTW5TRIG:
2680 case mfSCRITPTW6TRIG:
2681 case mfSCRITPTW7TRIG:
2682 case mfSCRITPTW8TRIG:
2683 case mfSCRITPTW9TRIG:
2684 case mfSCRITPTW10TRIG:
2685 case mfTROWEL:
2686 case mfTROWELNEXT:
2687 case mfTROWELSPECIALITEM:
2688 case mfSLASHPOT:
2689 case mfLIFTPOT:
2690 case mfLIFTORSLASH:
2691 case mfLIFTROCK:
2692 case mfLIFTROCKHEAVY:
2693 case mfDROPITEM:
2694 case mfSPECIALITEM:
2695 case mfDROPKEY:
2696 case mfDROPLKEY:
2697 case mfDROPCOMPASS:
2698 case mfDROPMAP:
2699 case mfDROPBOSSKEY:
2700 case mfSPAWNNPC:
2701 case mfSWITCHHOOK:
2702 case mfSIDEVIEWLADDER:
2703 case mfSIDEVIEWPLATFORM:
2704 case mfNOENEMYSPAWN:
2705 case mfENEMYALL:
2706 case mfNOMIRROR:
2707 case mfUNSAFEGROUND:
2708 case mf168:
2709 case mf169:
2710 case mf170:
2711 case mf171:
2712 case mf172:
2713 case mf173:
2714 case mf174:
2715 case mf175:
2716 case mf176:
2717 case mf177:
2718 case mf178:
2719 case mf179:
2720 case mf180:
2721 case mf181:
2722 case mf182:
2723 case mf183:
2724 case mf184:
2725 case mf185:
2726 case mf186:
2727 case mf187:
2728 case mf188:
2729 case mf189:
2730 case mf190:
2731 case mf191:
2732 case mf192:
2733 case mf193:
2734 case mf194:
2735 case mf195:
2736 case mf196:
2737 case mf197:
2738 case mf198:
2739 case mf199:
2740 case mf200:
2741 case mf201:
2742 case mf202:
2743 case mf203:
2744 case mf204:
2745 case mf205:
2746 case mf206:
2747 case mf207:
2748 case mf208:
2749 case mf209:
2750 case mf210:
2751 case mf211:
2752 case mf212:
2753 case mf213:
2754 case mf214:
2755 case mf215:
2756 case mf216:
2757 case mf217:
2758 case mf218:
2759 case mf219:
2760 case mf220:
2761 case mf221:
2762 case mf222:
2763 case mf223:
2764 case mf224:
2765 case mf225:
2766 case mf226:
2767 case mf227:
2768 case mf228:
2769 case mf229:
2770 case mf230:
2771 case mf231:
2772 case mf232:
2773 case mf233:
2774 case mf234:
2775 case mf235:
2776 case mf236:
2777 case mf237:
2778 case mf238:
2779 case mf239:
2780 case mf240:
2781 case mf241:
2782 case mf242:
2783 case mf243:
2784 case mf244:
2785 case mf245:
2786 case mf246:
2787 case mf247:
2788 case mf248:
2789 case mf249:
2790 case mf250:
2791 case mf251:
2792 case mf252:
2793 case mf253:
2794 case mf254:
2795 case mfEXTENDED:
2796 6894870 break;
2797
2798 case mfPUSHUD:
2799 case mfPUSHLR:
2800 case mfPUSH4:
2801 case mfPUSHU:
2802 case mfPUSHD:
2803 case mfPUSHL:
2804 case mfPUSHR:
2805 case mfPUSHUDNS:
2806 case mfPUSHLRNS:
2807 case mfPUSH4NS:
2808 case mfPUSHUNS:
2809 case mfPUSHDNS:
2810 case mfPUSHLNS:
2811 case mfPUSHRNS:
2812 case mfPUSHUDINS:
2813 case mfPUSHLRINS:
2814 case mfPUSH4INS:
2815 case mfPUSHUINS:
2816 case mfPUSHDINS:
2817 case mfPUSHLINS:
2818 case mfPUSHRINS:
2819
3/4
✓ Branch 0 taken 1939 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
3258 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2820
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1939 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2821 {
2822 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2823 }
2824
2825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2826
3/6
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 738 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3258 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2827 {
2828
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 1032 times.
2520 if(hints)
2829 {
2830
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2831 {
2832 case cPUSH_HEAVY:
2833 case cPUSH_HW:
2834 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2835 72 tempitemx=x, tempitemy=y;
2836
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2838 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2839
2840 72 break;
2841
2842 case cPUSH_HEAVY2:
2843 case cPUSH_HW2:
2844 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2845 63 tempitemx=x, tempitemy=y;
2846
2847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2848 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849
2850 63 break;
2851 }
2852 1032 }
2853 2520 }
2854
2855 3258 break;
2856
2857 case mfWHISTLE:
2858
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2859 {
2860 tempitem=getItemID(itemsbuf,itype_whistle,1);
2861
2862 if(tempitem<0) break;
2863
2864 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2865 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2866 {
2867 tempitemx=x;
2868 tempitemy=y;
2869 }
2870
2871 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2872 }
2873
2874 2418 break;
2875
2876 //Why is this here?
2877 case mfFAIRY:
2878 case mfMAGICFAIRY:
2879 case mfALLFAIRY:
2880 if(hints)
2881 {
2882 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2883
2884 if(tempitem < 0) break;
2885
2886 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 tempitemx=x;
2890 tempitemy=y;
2891 }
2892
2893 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 break;
2897
2898 case mfANYFIRE:
2899
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2900 {
2901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2902 252 }
2903 else
2904 {
2905 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2906
2907
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2908
2909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 189 tempitemx=x;
2913 189 tempitemy=y;
2914 189 }
2915
2916 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 504 break;
2920
2921 case mfSTRONGFIRE:
2922 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2925 }
2926 else
2927 {
2928 tempitem=getItemID(itemsbuf,itype_candle,2);
2929
2930 if(tempitem<0) break;
2931
2932 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2933 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2934 {
2935 tempitemx=x;
2936 tempitemy=y;
2937 }
2938
2939 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2940 }
2941
2942 break;
2943
2944 case mfMAGICFIRE:
2945 if(!hints)
2946 {
2947 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2948 }
2949 else
2950 {
2951 tempitem=getItemID(itemsbuf,itype_wand,1);
2952
2953 if(tempitem<0) break;
2954
2955 tempweapon=wFire;
2956
2957 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2958 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2959 {
2960 tempitemx=x;
2961 tempitemy=y;
2962 }
2963 else
2964 {
2965 tempweaponx=x;
2966 tempweapony=y;
2967 }
2968
2969 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2970 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2971 }
2972
2973 break;
2974
2975 case mfDIVINEFIRE:
2976 if(!hints)
2977 {
2978 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2979 }
2980 else
2981 {
2982 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2983
2984 if(tempitem<0) break;
2985
2986 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2987 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2988 {
2989 tempitemx=x;
2990 tempitemy=y;
2991 }
2992
2993 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2994 }
2995
2996 break;
2997
2998 case mfARROW:
2999
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3000 {
3001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3002 732 }
3003 else
3004 {
3005 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3006
3007
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3008
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3010
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3011 {
3012 61 tempitemx=x;
3013 61 tempitemy=y;
3014 61 }
3015
3016 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3017 }
3018
3019 814 break;
3020
3021 case mfSARROW:
3022 if(!hints)
3023 {
3024 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3025 }
3026 else
3027 {
3028 tempitem=getItemID(itemsbuf,itype_arrow,2);
3029
3030 if(tempitem<0) break;
3031
3032 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3033 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3034 {
3035 tempitemx=x;
3036 tempitemy=y;
3037 }
3038
3039 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3040 }
3041
3042 break;
3043
3044 case mfGARROW:
3045 if(!hints)
3046 {
3047 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3048 }
3049 else
3050 {
3051 tempitem=getItemID(itemsbuf,itype_arrow,3);
3052
3053 if(tempitem<0) break;
3054
3055 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3056 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3057 {
3058 tempitemx=x;
3059 tempitemy=y;
3060 }
3061
3062 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3063 }
3064
3065 break;
3066
3067 case mfBOMB:
3068
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 76 times.
93 if(!hints)
3069 {
3070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3071 76 }
3072 else
3073 {
3074 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3075 17 tempweapon = wLitBomb;
3076
3077 //if (tempitem<0) break;
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3079
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3080 {
3081 12 tempweaponx=x;
3082 12 tempweapony=y;
3083 12 }
3084
3085 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3086 }
3087
3088 93 break;
3089
3090 case mfSBOMB:
3091
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3094 48 }
3095 else
3096 {
3097 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3098 //if (tempitem<0) break;
3099 48 tempweapon = wLitSBomb;
3100
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3102
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3103 {
3104 36 tempweaponx=x;
3105 36 tempweapony=y;
3106 36 }
3107
3108 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3109 }
3110
3111 96 break;
3112
3113 case mfARMOS_SECRET:
3114
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3117 12 }
3118 24 break;
3119
3120 case mfBRANG:
3121
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if(!hints)
3122 {
3123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3124 20 }
3125 else
3126 {
3127 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3128
3129
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3130
3131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3132
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3133 {
3134 4 tempitemx=x;
3135 4 tempitemy=y;
3136 4 }
3137
3138 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3139 }
3140
3141 25 break;
3142
3143 case mfMBRANG:
3144 if(!hints)
3145 {
3146 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3147 }
3148 else
3149 {
3150 tempitem=getItemID(itemsbuf,itype_brang,2);
3151
3152 if(tempitem<0) break;
3153
3154 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3155 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3156 {
3157 tempitemx=x;
3158 tempitemy=y;
3159 }
3160
3161 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3162 }
3163
3164 break;
3165
3166 case mfFBRANG:
3167 if(!hints)
3168 {
3169 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3170 }
3171 else
3172 {
3173 tempitem=getItemID(itemsbuf,itype_brang,3);
3174
3175 if(tempitem<0) break;
3176
3177 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3178 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3179 {
3180 tempitemx=x;
3181 tempitemy=y;
3182 }
3183
3184 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3185 }
3186
3187 break;
3188
3189 case mfWANDMAGIC:
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!hints)
3191 {
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3193 138 }
3194 else
3195 {
3196 tempitem=getItemID(itemsbuf,itype_wand,1);
3197
3198 if(tempitem<0) break;
3199
3200 tempweapon=itemsbuf[tempitem].wpn3;
3201
3202 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3203 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3204 {
3205 tempitemx=x;
3206 tempitemy=y;
3207 }
3208 else
3209 {
3210 tempweaponx=x;
3211 tempweapony=y;
3212 --lens_hint_weapon[wMagic][4];
3213
3214 if(lens_hint_weapon[wMagic][4]<-8)
3215 {
3216 lens_hint_weapon[wMagic][4]=8;
3217 }
3218 }
3219
3220 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3221 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3222 }
3223
3224 138 break;
3225
3226 case mfREFMAGIC:
3227
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3228 {
3229 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3230 }
3231 else
3232 {
3233 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3234
3235
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3236
3237 16 tempweapon=ewMagic;
3238
3239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3240
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3241 {
3242 13 tempitemx=x;
3243 13 tempitemy=y;
3244 13 }
3245 else
3246 {
3247 3 tempweaponx=x;
3248 3 tempweapony=y;
3249
3250
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3251 {
3252 1 --lens_hint_weapon[ewMagic][4];
3253 1 }
3254 else
3255 {
3256 2 ++lens_hint_weapon[ewMagic][4];
3257 }
3258
3259
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3260 {
3261 lens_hint_weapon[ewMagic][2]=up;
3262 }
3263
3264
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3265 {
3266 2 lens_hint_weapon[ewMagic][2]=down;
3267 2 }
3268 }
3269
3270 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3271 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3272 }
3273
3274 16 break;
3275
3276 case mfREFFIREBALL:
3277
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3278 {
3279 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3280 }
3281 else
3282 {
3283 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3284
3285
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3286
3287 16 tempweapon=ewFireball;
3288
3289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 12 tempitemx=x;
3293 12 tempitemy=y;
3294 12 tempweaponx=x;
3295 12 tempweapony=y;
3296 12 ++lens_hint_weapon[ewFireball][3];
3297
3298
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3299 {
3300 1 lens_hint_weapon[ewFireball][3]=-8;
3301 1 lens_hint_weapon[ewFireball][4]=8;
3302 1 }
3303
3304
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3305 {
3306 8 ++lens_hint_weapon[ewFireball][4];
3307 8 }
3308 else
3309 {
3310 4 --lens_hint_weapon[ewFireball][4];
3311 }
3312 12 }
3313
3314 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3315 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3316 }
3317
3318 16 break;
3319
3320 case mfSWORD:
3321
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3322 {
3323 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3324 }
3325 else
3326 {
3327 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3328
3329
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3330
3331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3332
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3333 {
3334 5 tempitemx=x;
3335 5 tempitemy=y;
3336 5 }
3337
3338 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3339 }
3340
3341 7 break;
3342
3343 case mfWSWORD:
3344 if(!hints)
3345 {
3346 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3347 }
3348 else
3349 {
3350 tempitem=getItemID(itemsbuf,itype_sword,2);
3351
3352 if(tempitem<0) break;
3353
3354 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3355 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3356 {
3357 tempitemx=x;
3358 tempitemy=y;
3359 }
3360
3361 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3362 }
3363
3364 break;
3365
3366 case mfMSWORD:
3367 if(!hints)
3368 {
3369 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3370 }
3371 else
3372 {
3373 tempitem=getItemID(itemsbuf,itype_sword,3);
3374
3375 if(tempitem<0) break;
3376
3377 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3378 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3379 {
3380 tempitemx=x;
3381 tempitemy=y;
3382 }
3383
3384 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3385 }
3386
3387 break;
3388
3389 case mfXSWORD:
3390 if(!hints)
3391 {
3392 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3393 }
3394 else
3395 {
3396 tempitem=getItemID(itemsbuf,itype_sword,4);
3397
3398 if(tempitem<0) break;
3399
3400 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3401 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3402 {
3403 tempitemx=x;
3404 tempitemy=y;
3405 }
3406
3407 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3408 }
3409
3410 break;
3411
3412 case mfSWORDBEAM:
3413
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3414 {
3415 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3416 }
3417 else
3418 {
3419 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3420
3421
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3422
3423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3424
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3425 {
3426 11 tempitemx=x;
3427 11 tempitemy=y;
3428 11 }
3429
3430 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3431 }
3432
3433 16 break;
3434
3435 case mfWSWORDBEAM:
3436 if(!hints)
3437 {
3438 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3439 }
3440 else
3441 {
3442 tempitem=getItemID(itemsbuf,itype_sword,2);
3443
3444 if(tempitem<0) break;
3445
3446 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3447 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3448 {
3449 tempitemx=x;
3450 tempitemy=y;
3451 }
3452
3453 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3454 }
3455
3456 break;
3457
3458 case mfMSWORDBEAM:
3459 if(!hints)
3460 {
3461 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3462 }
3463 else
3464 {
3465 tempitem=getItemID(itemsbuf,itype_sword,3);
3466
3467 if(tempitem<0) break;
3468
3469 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3470 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3471 {
3472 tempitemx=x;
3473 tempitemy=y;
3474 }
3475
3476 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3477 }
3478
3479 break;
3480
3481 case mfXSWORDBEAM:
3482 if(!hints)
3483 {
3484 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3485 }
3486 else
3487 {
3488 tempitem=getItemID(itemsbuf,itype_sword,4);
3489
3490 if(tempitem<0) break;
3491
3492 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3493 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3494 {
3495 tempitemx=x;
3496 tempitemy=y;
3497 }
3498
3499 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3500 }
3501
3502 break;
3503
3504 case mfHOOKSHOT:
3505
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3506 {
3507 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3508 }
3509 else
3510 {
3511 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3512
3513
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3514
3515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3516
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3517 {
3518 12 tempitemx=x;
3519 12 tempitemy=y;
3520 12 }
3521
3522 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3523 }
3524
3525 17 break;
3526
3527 case mfWAND:
3528
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3529 {
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3531 }
3532 else
3533 {
3534 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3535
3536
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3537
3538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3539
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3540 {
3541 28 tempitemx=x;
3542 28 tempitemy=y;
3543 28 }
3544
3545 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3546 }
3547
3548 35 break;
3549
3550 case mfHAMMER:
3551
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3552 {
3553 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3554 }
3555 else
3556 {
3557 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3558
3559
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3560
3561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3562
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3563 {
3564 13 tempitemx=x;
3565 13 tempitemy=y;
3566 13 }
3567
3568 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3569 }
3570
3571 17 break;
3572
3573 case mfARMOS_ITEM:
3574 case mfDIVE_ITEM:
3575
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2602 times.
2602 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3576 {
3577 2602 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3578 2602 }
3579 2602 break;
3580
3581 case 16:
3582 case 17:
3583 case 18:
3584 case 19:
3585 case 20:
3586 case 21:
3587 case 22:
3588 case 23:
3589 case 24:
3590 case 25:
3591 case 26:
3592 case 27:
3593 case 28:
3594 case 29:
3595 case 30:
3596 case 31:
3597
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 107890 times.
108898 if(!hints)
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107890 times.
215780 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3599 107890 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3600
3601 108898 break;
3602 case mfSECRETSNEXT:
3603 if(!hints)
3604 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3605 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3606
3607 break;
3608
3609 case mfSTRIKE:
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 {
3612 906 goto special;
3613 }
3614 else
3615 {
3616 break;
3617 }
3618
3619 28750 default: goto special;
3620
3621 special:
3622
8/8
✓ Branch 0 taken 14732 times.
✓ Branch 1 taken 14924 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 496 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29656 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3623 {
3624
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
✓ Branch 2 taken 4954 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1650 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6604 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3625 {
3626 4954 rectfill(dest,x,y,x+15,y+15,WHITE);
3627 4954 }
3628 6604 }
3629
3630 29656 break;
3631 }
3632 7043520 }
3633 3521760 }
3634
3635
2/2
✓ Branch 0 taken 10005 times.
✓ Branch 1 taken 10005 times.
20010 if(layer)
3636 {
3637
2/2
✓ Branch 0 taken 9646 times.
✓ Branch 1 taken 359 times.
10005 if(tmpscr->door[0]==dWALK)
3638 359 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3639
3640
2/2
✓ Branch 0 taken 9582 times.
✓ Branch 1 taken 423 times.
10005 if(tmpscr->door[1]==dWALK)
3641 423 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3642
3643
2/2
✓ Branch 0 taken 9423 times.
✓ Branch 1 taken 582 times.
10005 if(tmpscr->door[2]==dWALK)
3644 582 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3645
3646
2/2
✓ Branch 0 taken 9381 times.
✓ Branch 1 taken 624 times.
10005 if(tmpscr->door[3]==dWALK)
3647 624 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3648
3649
2/2
✓ Branch 0 taken 9962 times.
✓ Branch 1 taken 43 times.
10005 if(tmpscr->door[0]==dBOMB)
3650 {
3651 43 showbombeddoor(dest, 0);
3652 43 }
3653
3654
2/2
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 39 times.
10005 if(tmpscr->door[1]==dBOMB)
3655 {
3656 39 showbombeddoor(dest, 1);
3657 39 }
3658
3659
2/2
✓ Branch 0 taken 9999 times.
✓ Branch 1 taken 6 times.
10005 if(tmpscr->door[2]==dBOMB)
3660 {
3661 6 showbombeddoor(dest, 2);
3662 6 }
3663
3664
2/2
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 37 times.
10005 if(tmpscr->door[3]==dBOMB)
3665 {
3666 37 showbombeddoor(dest, 3);
3667 37 }
3668 10005 }
3669
3670
2/2
✓ Branch 0 taken 17976 times.
✓ Branch 1 taken 2034 times.
20010 if(tmpscr->stairx + tmpscr->stairy)
3671 {
3672
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3673 {
3674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3675 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3676 1123 }
3677 else
3678 {
3679
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3680 {
3681 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3682 48 int32_t tempitemx=-16;
3683 48 int32_t tempitemy=-16;
3684
3685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3686
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3687 {
3688 24 tempitemx=tmpscr->stairx;
3689 24 tempitemy=tmpscr->stairy+playing_field_offset;
3690 24 }
3691
3692 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3693 48 }
3694 }
3695 2034 }
3696 }
3697 20010 }
3698
3699 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3700
3701 9666 void draw_lens_over()
3702 {
3703 // Oh, what the heck.
3704 static BITMAP *lens_scr = NULL;
3705 static int32_t last_width = -1;
3706 9666 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3707
3708 // Only redraw the circle if the size has changed
3709
2/2
✓ Branch 0 taken 9647 times.
✓ Branch 1 taken 19 times.
9666 if(width != last_width)
3710 {
3711
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(lens_scr == NULL)
3712 {
3713 17 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3714 17 }
3715
3716 19 clear_to_color(lens_scr, BLACK);
3717 19 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3718 19 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3719 19 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3720 19 last_width=width;
3721 19 }
3722
3723 9666 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3724 9666 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3725 9666 }
3726
3727 //----------------------------------------------------------------
3728
3729 31797 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3730 {
3731 //recreating a big bitmap every frame is highly sluggish.
3732
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
31797 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3733 31797 clear_to_color(wavebuf, BLACK);
3734 31797 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3735
3736 int32_t ofs;
3737 // int32_t amplitude=8;
3738 // int32_t wavelength=4;
3739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31797 times.
31797 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3740
4/6
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
✓ Branch 4 taken 494 times.
✓ Branch 5 taken 31303 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3741 31797 int32_t amp2=168;
3742
2/4
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3743 31797 int32_t i=frame%amp2;
3744
3745
2/2
✓ Branch 0 taken 5341896 times.
✓ Branch 1 taken 31797 times.
5373693 for(int32_t j=0; j<168; j++)
3746 {
3747
3/4
✓ Branch 0 taken 2670948 times.
✓ Branch 1 taken 2670948 times.
✓ Branch 2 taken 2670948 times.
✗ Branch 3 not taken.
5341896 if(j&1 && interpol)
3748 {
3749 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3750 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3751 }
3752 else
3753 {
3754 5341896 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3755 }
3756
3757
1/2
✓ Branch 0 taken 5341896 times.
✗ Branch 1 not taken.
5341896 if(ofs)
3758 {
3759
2/2
✓ Branch 0 taken 1367525376 times.
✓ Branch 1 taken 5341896 times.
1372867272 for(int32_t k=0; k<256; k++)
3760 {
3761 1367525376 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3762 1367525376 }
3763 5341896 }
3764 5341896 }
3765 31797 }
3766
3767 28224 void draw_fuzzy(int32_t fuzz)
3768 // draws from right half of scrollbuf to framebuf
3769 {
3770 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3771 byte *start, *si, *di;
3772
3773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(fuzz<1)
3774 fuzz = 1;
3775
3776 28224 xstep = 128%fuzz;
3777
3778
2/2
✓ Branch 0 taken 5880 times.
✓ Branch 1 taken 22344 times.
28224 if(xstep > 0)
3779 22344 xstep = fuzz-xstep;
3780
3781 28224 ystep = 112%fuzz;
3782
3783
2/2
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 19992 times.
28224 if(ystep > 0)
3784 19992 ystep = fuzz-ystep;
3785
3786 28224 firsty = 1;
3787
3788
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 1018416 times.
1046640 for(y=0; y<224;)
3789 {
3790 1018416 start = &(scrollbuf->line[y][256]);
3791
3792
4/4
✓ Branch 0 taken 1004304 times.
✓ Branch 1 taken 6336288 times.
✓ Branch 2 taken 6322176 times.
✓ Branch 3 taken 1018416 times.
7340592 for(dy=0; dy<ystep && dy+y<224; dy++)
3793 {
3794 6322176 si = start;
3795 6322176 di = &(framebuf->line[y+dy][0]);
3796 6322176 i = xstep;
3797 6322176 firstx = 1;
3798
3799
2/2
✓ Branch 0 taken 1618477056 times.
✓ Branch 1 taken 6322176 times.
1624799232 for(dx=0; dx<256; dx++)
3800 {
3801 1618477056 *(di++) = *si;
3802
3803
2/2
✓ Branch 0 taken 1363746048 times.
✓ Branch 1 taken 254731008 times.
1618477056 if(++i >= fuzz)
3804 {
3805
2/2
✓ Branch 0 taken 248408832 times.
✓ Branch 1 taken 6322176 times.
254731008 if(!firstx)
3806 248408832 si += fuzz;
3807 else
3808 {
3809 6322176 si += fuzz-xstep;
3810 6322176 firstx = 0;
3811 }
3812
3813 254731008 i = 0;
3814 254731008 }
3815 1618477056 }
3816 6322176 }
3817
3818
2/2
✓ Branch 0 taken 990192 times.
✓ Branch 1 taken 28224 times.
1018416 if(!firsty)
3819 990192 y += fuzz;
3820 else
3821 {
3822 28224 y += ystep;
3823 28224 ystep = fuzz;
3824 28224 firsty = 0;
3825 }
3826 }
3827 28224 }
3828
3829 18328844 void updatescr(bool allowwavy)
3830 {
3831
4/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 18328578 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 266 times.
✗ Branch 5 not taken.
18328844 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3832
4/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 18328578 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 266 times.
18328844 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3833
3834
2/2
✓ Branch 0 taken 18301539 times.
✓ Branch 1 taken 27305 times.
18328844 if(toogam)
3835 {
3836 27305 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3837 27305 }
3838
3839
1/2
✓ Branch 0 taken 18328844 times.
✗ Branch 1 not taken.
18328844 if(Showpal)
3840 dump_pal(framebuf);
3841
3842
2/2
✓ Branch 0 taken 17815441 times.
✓ Branch 1 taken 513403 times.
18328844 if(!Playing)
3843 513403 black_opening_count=0;
3844
3845
2/2
✓ Branch 0 taken 18164226 times.
✓ Branch 1 taken 164618 times.
18328844 if(black_opening_count<0) //shape is opening up
3846 {
3847 164618 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3848
3849
2/4
✓ Branch 0 taken 164618 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 164618 times.
164618 if(Advance||(!Paused))
3850 {
3851 164618 ++black_opening_count;
3852 164618 }
3853 164618 }
3854
2/2
✓ Branch 0 taken 18116244 times.
✓ Branch 1 taken 47982 times.
18164226 else if(black_opening_count>0) //shape is closing
3855 {
3856 47982 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3857
3858
2/4
✓ Branch 0 taken 47982 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47982 times.
47982 if(Advance||(!Paused))
3859 {
3860 47982 --black_opening_count;
3861 47982 }
3862 47982 }
3863
3864
3/4
✓ Branch 0 taken 18119465 times.
✓ Branch 1 taken 209379 times.
✓ Branch 2 taken 18119465 times.
✗ Branch 3 not taken.
18328844 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3865 {
3866 black_opening_shape = bosCIRCLE;
3867 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3868 refreshTints();
3869 refreshpal=true;
3870 }
3871
3872
2/2
✓ Branch 0 taken 17700042 times.
✓ Branch 1 taken 628802 times.
18328844 if(refreshpal)
3873 {
3874 628802 refreshpal=false;
3875 628802 RAMpal[253] = _RGB(0,0,0);
3876 628802 RAMpal[254] = _RGB(63,63,63);
3877 628802 hw_palette = &RAMpal;
3878 628802 update_hw_pal = true;
3879
3880 // Creating rgb_table and trans_table is pretty expensive, so try not to redo the same work
3881 // within a short period of time by using a cache.
3882 typedef std::array<uint32_t, PAL_SIZE> pal_table_cache_key;
3883 struct pal_table_cache_entry {
3884 RGB_MAP rgb_table;
3885 COLOR_MAP trans_table;
3886 };
3887
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 628536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
628802 static std::map<pal_table_cache_key, pal_table_cache_entry> pal_table_cache;
3888
3889 static constexpr int pal_table_cache_max_memory_mb = 10;
3890 static constexpr int pal_table_cache_max_size = pal_table_cache_max_memory_mb / ((double)sizeof(pal_table_cache_entry) / 1024 / 1024);
3891
2/2
✓ Branch 0 taken 628624 times.
✓ Branch 1 taken 178 times.
628802 if (pal_table_cache.size() > pal_table_cache_max_size)
3892 178 pal_table_cache.clear();
3893
3894 pal_table_cache_key key;
3895
2/2
✓ Branch 0 taken 160973312 times.
✓ Branch 1 taken 628802 times.
161602114 for (int i = 0; i < PAL_SIZE; i++)
3896 160973312 key[i] = RAMpal[i].r + (RAMpal[i].g << 8) + (RAMpal[i].b << 16);
3897 628802 auto cache_it = pal_table_cache.find(key);
3898
2/2
✓ Branch 0 taken 26328 times.
✓ Branch 1 taken 602474 times.
628802 if (cache_it == pal_table_cache.end())
3899 {
3900 26328 create_rgb_table(&rgb_table, RAMpal, NULL);
3901 26328 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3902 26328 pal_table_cache[key] = {rgb_table, trans_table};
3903 26328 trans_table2 = trans_table;
3904 26328 }
3905 else
3906 {
3907 602474 rgb_table = cache_it->second.rgb_table;
3908 602474 trans_table = cache_it->second.trans_table;
3909 602474 trans_table2 = cache_it->second.trans_table;
3910 }
3911
3912
2/2
✓ Branch 0 taken 160973312 times.
✓ Branch 1 taken 628802 times.
161602114 for(int32_t q=0; q<PAL_SIZE; q++)
3913 {
3914 160973312 trans_table2.data[0][q] = q;
3915 160973312 trans_table2.data[q][q] = q;
3916 160973312 }
3917 628802 }
3918
3919 18328844 bool clearwavy = (wavy <= 0);
3920
3921
2/2
✓ Branch 0 taken 8341 times.
✓ Branch 1 taken 18320503 times.
18328844 if(wavy <= 0)
3922 {
3923 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3924 18320503 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3925 18320503 }
3926
3927 18328844 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3928
3929
6/6
✓ Branch 0 taken 32047 times.
✓ Branch 1 taken 18296797 times.
✓ Branch 2 taken 31925 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31797 times.
18328844 if(wavy && Playing && allowwavy)
3930 {
3931 31797 draw_wavy(framebuf, wavybuf, wavy,false);
3932 31797 }
3933
3934
2/2
✓ Branch 0 taken 18320503 times.
✓ Branch 1 taken 8341 times.
18328844 if(clearwavy)
3935 18320503 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3936
2/4
✓ Branch 0 taken 8341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8341 times.
8341 else if(Playing && !Paused)
3937 8341 wavy--; // Wavy was set by a script. Decrement it.
3938
3939
5/6
✓ Branch 0 taken 17815441 times.
✓ Branch 1 taken 513403 times.
✓ Branch 2 taken 664395 times.
✓ Branch 3 taken 17151046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 664395 times.
18328844 if(Playing && msgpos && !screenscrolling)
3940 {
3941
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_bg_display_buf->clip))
3942 664395 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3943
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_portrait_display_buf->clip))
3944 664395 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3945
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_txt_display_buf->clip))
3946 664395 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3947 664395 }
3948
3949 /*
3950 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3951 {
3952 BITMAP* subBmp = 0;
3953 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3954 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3955 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3956 destroy_bitmap(subBmp);
3957 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3958 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3959 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3960 }
3961 */
3962
3963
2/2
✓ Branch 0 taken 18142335 times.
✓ Branch 1 taken 186509 times.
18328844 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3964
3965
2/2
✓ Branch 0 taken 18147608 times.
✓ Branch 1 taken 181236 times.
18328844 if(nosubscr)
3966 {
3967 181236 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3968 181236 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3969 181236 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3970 181236 }
3971
3972 //TODO: Optimize blit 'overcalls' -Gleeok
3973
2/2
✓ Branch 0 taken 181236 times.
✓ Branch 1 taken 18147608 times.
18328844 BITMAP *source = nosubscr ? panorama : wavybuf;
3974 18328844 blit(source,framebuf,0,0,0,0,256,224);
3975
3976 18328844 update_hw_screen();
3977 18328844 }
3978
3979 //----------------------------------------------------------------
3980
3981 static PALETTE syspal;
3982 int32_t onGUISnapshot()
3983 {
3984 char buf[200];
3985 int32_t num=0;
3986 do
3987 {
3988 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3989 }
3990 while(num<99999 && exists(buf));
3991
3992 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3993 InfoDialog("Error", "Failed to save snapshot").show();
3994
3995 return D_O_K;
3996 }
3997
3998 int32_t onNonGUISnapshot()
3999 {
4000 PALETTE temppal;
4001 get_palette(temppal);
4002 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
4003
4004 char buf[200];
4005 int32_t num=0;
4006
4007 do
4008 {
4009 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4010 }
4011 while(num<99999 && exists(buf));
4012
4013 if ((tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET)) && !(key[KEY_ALT]))
4014 {
4015 BITMAP *b = create_bitmap_ex(8,256,168);
4016 clear_to_color(b,0);
4017 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
4018 alleg4_save_bitmap(b, SnapshotScale, buf, realpal ? temppal : RAMpal);
4019 destroy_bitmap(b);
4020 }
4021 else
4022 {
4023 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
4024 }
4025
4026 return D_O_K;
4027 }
4028
4029 int32_t onSnapshot()
4030 {
4031 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4032 {
4033 onGUISnapshot();
4034 }
4035 else
4036 {
4037 onNonGUISnapshot();
4038 }
4039
4040 return D_O_K;
4041 }
4042
4043 int32_t onSaveMapPic()
4044 {
4045 int32_t mapres2 = 0;
4046 char buf[200];
4047 int32_t num=0;
4048 mapscr tmpscr_b[2];
4049 mapscr tmpscr_c[6];
4050 BITMAP* _screen_draw_buffer = NULL;
4051 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4052 set_clip_state(_screen_draw_buffer,1);
4053
4054 for(int32_t i=0; i<6; ++i)
4055 {
4056 tmpscr_c[i] = tmpscr2[i];
4057 tmpscr2[i].zero_memory();
4058
4059 if(i>=2)
4060 {
4061 continue;
4062 }
4063
4064 tmpscr_b[i] = tmpscr[i];
4065 tmpscr[i].zero_memory();
4066 }
4067
4068 do
4069 {
4070 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4071 }
4072 while(num<99999 && exists(buf));
4073
4074 BITMAP* mappic = NULL;
4075
4076
4077 bool done=false, redraw=true;
4078
4079 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4080
4081 if(!mappic)
4082 {
4083 enter_sys_pal();
4084 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4085 exit_sys_pal();
4086 return D_O_K;;
4087 }
4088
4089 // draw the map
4090 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4091
4092 for(int32_t y=0; y<8; y++)
4093 {
4094 for(int32_t x=0; x<16; x++)
4095 {
4096 if(!displayOnMap(x, y))
4097 {
4098 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4099 }
4100 else
4101 {
4102 int32_t s = (y<<4) + x;
4103 loadscr2(1,s,-1);
4104
4105 for(int32_t i=0; i<6; i++)
4106 {
4107 if(tmpscr[1].layermap[i]<=0)
4108 continue;
4109
4110 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4111 }
4112
4113 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4114
4115 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4116
4117 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4118 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4119
4120 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4121
4122 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4123 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4124 {
4125 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4126 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4127 {
4128 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4129 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4130 }
4131 }
4132 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4133
4134 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4135
4136 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4137 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4138 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4139 {
4140 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4141 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4142 }
4143 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4144 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4145
4146 }
4147
4148 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4149 }
4150 }
4151
4152 for(int32_t i=0; i<6; ++i)
4153 {
4154 tmpscr2[i]=tmpscr_c[i];
4155
4156 if(i>=2)
4157 {
4158 continue;
4159 }
4160
4161 tmpscr[i]=tmpscr_b[i];
4162 }
4163
4164 save_bitmap(buf,mappic,RAMpal);
4165 destroy_bitmap(mappic);
4166 destroy_bitmap(_screen_draw_buffer);
4167 return D_O_K;
4168 }
4169
4170 61 void f_Quit(int32_t type)
4171 {
4172
2/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
61 if(type==qQUIT && !Playing)
4173 return;
4174
4175 61 bool from_menu = is_sys_pal;
4176
4177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4178 {
4179 61 music_pause();
4180 61 pause_all_sfx();
4181 61 sys_mouse();
4182 61 }
4183 61 enter_sys_pal();
4184 61 clear_keybuf();
4185
4186
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 13 times.
61 if (replay_version_check(0, 10))
4187 13 replay_poll();
4188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if (replay_is_replaying())
4189 61 replay_peek_quit();
4190
4191
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (!replay_is_replaying())
4192 switch(type)
4193 {
4194 case qQUIT:
4195 onQuit();
4196 break;
4197
4198 case qRESET:
4199 onReset();
4200 break;
4201
4202 case qEXIT:
4203 onExit();
4204 break;
4205 }
4206
4207
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(Quit)
4208 {
4209 61 kill_sfx();
4210 61 music_stop();
4211 61 exit_sys_pal();
4212 61 update_hw_screen();
4213 61 }
4214 else
4215 {
4216 exit_sys_pal();
4217 if(!from_menu)
4218 {
4219 music_resume();
4220 resume_all_sfx();
4221 }
4222 }
4223
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4225 61 game_mouse();
4226 61 eat_buttons();
4227
4228 61 zc_readrawkey(KEY_ESC);
4229
4230 61 zc_readrawkey(KEY_ENTER);
4231 61 }
4232
4233 //----------------------------------------------------------------
4234
4235 int32_t onNoWalls()
4236 {
4237 cheats_enqueue(Cheat::Walls);
4238 return D_O_K;
4239 }
4240
4241 int32_t onIgnoreSideview()
4242 {
4243 cheats_enqueue(Cheat::IgnoreSideView);
4244 return D_O_K;
4245 }
4246
4247 18327501 int32_t input_idle(bool checkmouse)
4248 {
4249 static int32_t mx, my, mz, mb;
4250
4251
4/6
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4911000 times.
✓ Branch 3 taken 13416501 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4911000 times.
23238501 if(keypressed() || zc_key_pressed() ||
4252
4/8
✓ Branch 0 taken 4911000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4911000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4911000 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4911000 times.
✗ Branch 7 not taken.
4911000 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4253 {
4254 13416501 idle_count = 0;
4255
4256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13416501 times.
13416501 if(active_count < MAX_ACTIVE)
4257 {
4258 13416501 ++active_count;
4259 13416501 }
4260 13416501 }
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4911000 times.
4911000 else if(idle_count < MAX_IDLE)
4262 {
4263 4911000 ++idle_count;
4264 4911000 active_count = 0;
4265 4911000 }
4266
4267 18327501 mx = mouse_x;
4268 18327501 my = mouse_y;
4269 18327501 mz = mouse_z;
4270 18327501 mb = mouse_b;
4271
4272 18327501 return idle_count;
4273 }
4274
4275 int32_t onGoFast()
4276 {
4277 cheats_enqueue(Cheat::Fast);
4278 return D_O_K;
4279 }
4280
4281 int32_t onKillCheat()
4282 {
4283 cheats_enqueue(Cheat::Kill);
4284 return D_O_K;
4285 }
4286
4287 int32_t onSecretsCheat()
4288 {
4289 cheats_enqueue(Cheat::TrigSecrets);
4290 return D_O_K;
4291 }
4292 int32_t onSecretsCheatPerm()
4293 {
4294 cheats_enqueue(Cheat::TrigSecretsPerm);
4295 return D_O_K;
4296 }
4297
4298 int32_t onShowLayer0()
4299 {
4300 show_layer_0 = !show_layer_0;
4301 return D_O_K;
4302 }
4303 int32_t onShowLayer1()
4304 {
4305 show_layer_1 = !show_layer_1;
4306 return D_O_K;
4307 }
4308 int32_t onShowLayer2()
4309 {
4310 show_layer_2 = !show_layer_2;
4311 return D_O_K;
4312 }
4313 int32_t onShowLayer3()
4314 {
4315 show_layer_3 = !show_layer_3;
4316 return D_O_K;
4317 }
4318 int32_t onShowLayer4()
4319 {
4320 show_layer_4 = !show_layer_4;
4321 return D_O_K;
4322 }
4323 int32_t onShowLayer5()
4324 {
4325 show_layer_5 = !show_layer_5;
4326 return D_O_K;
4327 }
4328 int32_t onShowLayer6()
4329 {
4330 show_layer_6 = !show_layer_6;
4331 return D_O_K;
4332 }
4333 int32_t onShowLayerO()
4334 {
4335 show_layer_over=!show_layer_over;
4336 return D_O_K;
4337 }
4338 int32_t onShowLayerP()
4339 {
4340 show_layer_push=!show_layer_push;
4341 return D_O_K;
4342 }
4343 int32_t onShowLayerS()
4344 {
4345 show_sprites=!show_sprites;
4346 return D_O_K;
4347 }
4348 int32_t onShowLayerF()
4349 {
4350 show_ffcs=!show_ffcs;
4351 return D_O_K;
4352 }
4353 int32_t onShowLayerW()
4354 {
4355 show_walkflags=!show_walkflags;
4356 if(show_walkflags)
4357 show_effectflags = false;
4358 return D_O_K;
4359 }
4360 int32_t onShowLayerE()
4361 {
4362 show_effectflags=!show_effectflags;
4363 if(show_effectflags)
4364 show_walkflags = false;
4365 return D_O_K;
4366 }
4367 int32_t onShowFFScripts()
4368 {
4369 show_ff_scripts=!show_ff_scripts;
4370 return D_O_K;
4371 }
4372 int32_t onShowHitboxes()
4373 {
4374 show_hitboxes=!show_hitboxes;
4375 return D_O_K;
4376 }
4377 int32_t onShowInfoOpacity()
4378 {
4379 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4380 zc_set_config("zc","debug_info_opacity",info_opacity);
4381 return D_O_K;
4382 }
4383
4384 int32_t onLightSwitch()
4385 {
4386 cheats_enqueue(Cheat::Light);
4387 return D_O_K;
4388 }
4389
4390 int32_t onGoTo();
4391 int32_t onGoToComplete();
4392
4393 18327501 bool handle_close_btn_quit()
4394 {
4395
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(close_button_quit)
4396 {
4397 close_button_quit=false;
4398 f_Quit(qEXIT);
4399 }
4400 18327501 return (exiting_program = Quit==qEXIT);
4401 }
4402
4403 18327501 void syskeys()
4404 {
4405 18327501 update_system_keys();
4406
4407 int32_t oldtitle_version;
4408
4409 18327501 poll_joystick();
4410
4411 18327501 handle_close_btn_quit();
4412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
18327501 if(Quit == qEXIT) return;
4413
4414
2/10
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18327501 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18327501 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4415 {
4416 System();
4417 }
4418
4419 18327501 mouse_down=gui_mouse_b();
4420
4421
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(zc_read_system_key(KEY_F1))
4422 {
4423 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4424 {
4425 halt=!halt;
4426 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4427 }
4428 else
4429 {
4430 Throttlefps=!Throttlefps;
4431 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4432 }
4433 }
4434
4435
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(zc_read_system_key(KEY_F2))
4436 {
4437 ShowFPS=!ShowFPS;
4438 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4439 }
4440
4441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18327501 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4442
4443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18327501 if(zc_read_system_key(KEY_F4) && Playing)
4444 {
4445 Paused=true;
4446 Advance=true;
4447 }
4448
4449
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(zc_read_system_key(KEY_F6)) onTryQuit();
4450
4451 #ifndef ALLEGRO_MACOSX
4452
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4453
4454
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4455 #else
4456 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4457
4458 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4459 #endif
4460
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18327501 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4461
4462
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if (zc_read_system_key(KEY_F12))
4463 {
4464 onSnapshot();
4465 }
4466
4467
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18327501 if(debug_enabled && zc_read_system_key(KEY_TAB))
4468 set_debug(!get_debug());
4469
4470
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(CheatModifierKeys())
4471 {
4472 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4473 {
4474 if(!bindable_cheat(c))
4475 continue;
4476 if(get_debug() || cheat >= cheat_lvl(c))
4477 {
4478 if(checkcheat(c))
4479 cheats_hit_bind(c);
4480 }
4481 }
4482 }
4483
4484
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(volkeys)
4485 {
4486 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4487
4488 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4489
4490 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4491
4492 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4493 }
4494
4495
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18327501 if(!get_debug() || !SystemKeys || replay_is_replaying())
4496 18327501 goto bottom;
4497
4498 if(zc_readkey(KEY_P)) Paused=!Paused;
4499
4500 //if(zc_readkey(KEY_P)) centerHero();
4501 if(zc_readkey(KEY_A))
4502 {
4503 Paused=true;
4504 Advance=true;
4505 }
4506
4507 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4508 #ifndef ALLEGRO_MACOSX
4509 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4510
4511 if(zc_readkey(KEY_F7))
4512 {
4513 Matrix(ss_speed, ss_density, 0);
4514 game_pal();
4515 }
4516 #else
4517 // The reason these are different on Mac in the first place is that
4518 // the OS doesn't let us use F9 and F10...
4519 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4520
4521 if(zc_readkey(KEY_F9))
4522 {
4523 Matrix(ss_speed, ss_density, 0);
4524 game_pal();
4525 }
4526 #endif
4527 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4528 {
4529 //change containers
4530 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4531 {
4532 //magic containers
4533 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4534 {
4535 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4536 }
4537 else
4538 {
4539 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4540 }
4541 }
4542 else
4543 {
4544 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4545 {
4546 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4547 }
4548 else
4549 {
4550 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4551 }
4552 }
4553 }
4554
4555 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4556 {
4557 //change containers
4558 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4559 {
4560 //magic containers
4561 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4562 {
4563 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4564 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4565 //heart containers
4566 }
4567 else
4568 {
4569 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4570 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4571 }
4572 }
4573 else
4574 {
4575 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4576 {
4577 game->set_magic(zc_max(game->get_magic()-1,0));
4578 }
4579 else
4580 {
4581 game->set_life(zc_max(game->get_life()-1,0));
4582 }
4583 }
4584 }
4585
4586 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4587
4588 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4589
4590 verifyBothWeapons();
4591
4592 bottom:
4593
4594
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(input_idle(true) > after_time())
4595 {
4596 Matrix(ss_speed, ss_density, 0);
4597 game_pal();
4598 }
4599 18327501 }
4600
4601 1129077 void checkQuitKeys()
4602 {
4603 #ifndef ALLEGRO_MACOSX
4604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1129077 times.
1129077 if(key[KEY_F9]) f_Quit(qRESET);
4605
4606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1129077 times.
1129077 if(key[KEY_F10]) f_Quit(qEXIT);
4607 #else
4608 if(key[KEY_F7]) f_Quit(qRESET);
4609
4610 if(key[KEY_F8]) f_Quit(qEXIT);
4611 #endif
4612 1129077 }
4613
4614 18327701 bool CheatModifierKeys()
4615 {
4616 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4617 // to trigger cheats.
4618
2/2
✓ Branch 0 taken 18327401 times.
✓ Branch 1 taken 300 times.
18327701 if (replay_is_replaying())
4619 18327401 return false;
4620
4621
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
300 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4622
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 100 times.
200 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4624 {
4625
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4626 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4627 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4628 {
4629 return true;
4630 }
4631 }
4632 100 return false;
4633 18327501 }
4634
4635 //99:05:54, for some reason?
4636 #define OLDMAXTIME 21405240
4637 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4638 #define MAXTIME 1944000000
4639
4640 18328844 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4641 {
4642
1/2
✓ Branch 0 taken 18328844 times.
✗ Branch 1 not taken.
18328844 if(zcmusic!=NULL)
4643 {
4644 zcmusic_poll();
4645 }
4646 18328844 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4647
4648 18328844 updatescr(allowwavy);
4649
4650 18328844 Advance=false;
4651
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18328844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18328844 times.
18328844 while(Paused && !Advance && !Quit)
4652 {
4653 // have to call this, otherwise we'll get an infinite loop
4654 syskeys();
4655 if(allowF6Script)
4656 {
4657 FFCore.runF6Engine();
4658 }
4659
4660 #ifdef _WIN32
4661
4662 if(use_dwm_flush)
4663 {
4664 do_DwmFlush();
4665 }
4666
4667 #endif
4668
4669 // to keep music playing
4670 if(zcmusic!=NULL)
4671 {
4672 zcmusic_poll();
4673 }
4674
4675 update_hw_screen();
4676 }
4677
4678
2/2
✓ Branch 0 taken 18327545 times.
✓ Branch 1 taken 1299 times.
18328844 if(Quit)
4679 1299 return;
4680
4681
3/4
✓ Branch 0 taken 17814444 times.
✓ Branch 1 taken 513101 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17814444 times.
18327545 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4682 17814444 game->change_time(1);
4683
4684 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4685
4686 18327545 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4687
2/2
✓ Branch 0 taken 8617246 times.
✓ Branch 1 taken 9710299 times.
18327545 if (replay_version_check(0, 16))
4688 9710299 should_reset_down_state = replay_version_check(11, 16);
4689
2/2
✓ Branch 0 taken 14976688 times.
✓ Branch 1 taken 3350857 times.
18327545 if (should_reset_down_state)
4690 {
4691
2/2
✓ Branch 0 taken 60315426 times.
✓ Branch 1 taken 3350857 times.
63666283 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4692 60315426 down_control_states[i] = raw_control_state[i];
4693 3350857 }
4694
4695
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 18327501 times.
18327545 if (replay_is_active())
4696 {
4697
2/2
✓ Branch 0 taken 1545413 times.
✓ Branch 1 taken 16782088 times.
18327501 if (replay_version_check(3))
4698 16782088 replay_poll();
4699
4700
4/4
✓ Branch 0 taken 7389596 times.
✓ Branch 1 taken 10937905 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 7289061 times.
18327501 if (replay_version_check(11) || replay_version_check(6, 8))
4701 11038440 replay_peek_input();
4702 18327501 }
4703
4704 18327545 load_control_called_this_frame = false;
4705
4706 18327545 poll_keyboard();
4707 18327545 update_keys();
4708
4709 18327545 ++frame;
4710
4711
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 18327401 times.
18327545 if (replay_is_replaying())
4712 18327401 replay_do_cheats();
4713 18327545 syskeys();
4714
4715 // The mouse variables can change from the mouse thread at anytime during a frame,
4716 // so save the result at the start so that replaying is consistent.
4717 18327545 script_mouse_x = gui_mouse_x();
4718 18327545 script_mouse_y = gui_mouse_y();
4719 18327545 script_mouse_z = mouse_z;
4720 18327545 script_mouse_b = mouse_b;
4721
4722 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4723 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4724 // approach here means it doesn't matter which call adds the cheat.
4725 18327545 cheats_execute_queued();
4726
4727
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 18327401 times.
18327545 if (replay_is_replaying())
4728 18327401 replay_peek_quit();
4729
2/2
✓ Branch 0 taken 18327484 times.
✓ Branch 1 taken 61 times.
18327545 if (GameFlags & GAMEFLAG_TRYQUIT)
4730 61 replay_step_quit(0);
4731
2/2
✓ Branch 0 taken 3694 times.
✓ Branch 1 taken 18323851 times.
18327545 if(allowF6Script)
4732 18323851 FFCore.runF6Engine();
4733
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 18326805 times.
18327545 if (Quit)
4734 740 replay_step_quit(Quit);
4735
4736 #ifdef _WIN32
4737
4738 if(use_dwm_flush)
4739 {
4740 do_DwmFlush();
4741 }
4742
4743 #endif
4744
4745 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4746
2/2
✓ Branch 0 taken 208652 times.
✓ Branch 1 taken 18118893 times.
18327545 if(sfxcleanup)
4747 18118893 sfx_cleanup();
4748
4749 18327545 jit_poll();
4750
4751 #ifdef __EMSCRIPTEN__
4752 // Yield the main thread back to the browser occasionally.
4753 if (is_headless())
4754 {
4755 static int rate = 10000;
4756 static int force_yield = rate;
4757 if (force_yield++ >= rate)
4758 {
4759 force_yield = 0;
4760 emscripten_sleep(0);
4761 }
4762 }
4763 #endif
4764
4765
4/6
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 18327286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
18327545 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4766
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 18327445 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
18327545 if (zqtesting_mode && test_mode_auto_restart)
4767 {
4768 static auto last_write_time = fs::last_write_time(qstpath);
4769 static auto last_check = std::chrono::system_clock::now();
4770
4771 if (std::chrono::system_clock::now() - last_check > 200ms)
4772 {
4773 last_check = std::chrono::system_clock::now();
4774 auto write_time = fs::last_write_time(qstpath);
4775 if (last_write_time != write_time)
4776 {
4777 last_write_time = write_time;
4778 disableClickToFreeze = false;
4779 Quit = qRESET;
4780 replay_quit();
4781 }
4782 }
4783 }
4784 18328844 }
4785
4786 589 void zapout()
4787 {
4788 589 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4789 589 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4790
4791 589 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4792 589 script_drawing_commands.Clear();
4793
4794 // zap out
4795
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 14136 times.
14725 for(int32_t i=1; i<=24; i++)
4796 {
4797 14136 draw_fuzzy(i);
4798 14136 advanceframe(true);
4799
4800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14136 times.
14136 if(Quit)
4801 {
4802 break;
4803 }
4804 14136 }
4805 589 }
4806
4807 587 void zapin()
4808 {
4809 587 FFCore.warpScriptCheck();
4810 587 draw_screen(tmpscr);
4811 587 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4812 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4813 587 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4814
4815 // zap out
4816 587 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4817
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 14088 times.
14675 for(int32_t i=24; i>=1; i--)
4818 {
4819 14088 draw_fuzzy(i);
4820 14088 advanceframe(true);
4821
4822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14088 times.
14088 if(Quit)
4823 {
4824 break;
4825 }
4826 14088 }
4827 587 }
4828
4829
4830 235 void wavyout(bool showhero)
4831 {
4832 235 draw_screen(tmpscr, showhero);
4833 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4834
4835 235 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4836 235 clear_to_color(wavebuf,0);
4837 235 blit(framebuf,wavebuf,0,0,16,0,256,224);
4838
4839 static PALETTE wavepal;
4840
4841 int32_t ofs;
4842 235 int32_t amplitude=8;
4843
4844 235 int32_t wavelength=4;
4845 235 double palpos=0, palstep=4, palstop=126;
4846
4847 235 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4848
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 9845 times.
10079 for(int32_t i=0; i<168; i+=wavelength)
4849 {
4850
2/2
✓ Branch 0 taken 2520320 times.
✓ Branch 1 taken 9845 times.
2530165 for(int32_t l=0; l<256; l++)
4851 {
4852 2520320 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4853 2520320 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4854 2520320 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4855 2520320 }
4856
4857 9845 palpos+=palstep;
4858
4859
1/2
✓ Branch 0 taken 9845 times.
✗ Branch 1 not taken.
9845 if(palpos>=0)
4860 {
4861 9845 hw_palette = &wavepal;
4862 9845 update_hw_pal = true;
4863 9845 }
4864 else
4865 {
4866 hw_palette = &RAMpal;
4867 update_hw_pal = true;
4868 }
4869
4870
2/2
✓ Branch 0 taken 1653960 times.
✓ Branch 1 taken 9845 times.
1663805 for(int32_t j=0; j+playing_field_offset<224; j++)
4871 {
4872
2/2
✓ Branch 0 taken 423413760 times.
✓ Branch 1 taken 1653960 times.
425067720 for(int32_t k=0; k<256; k++)
4873 {
4874 423413760 ofs=0;
4875
4876
4/4
✓ Branch 0 taken 206448640 times.
✓ Branch 1 taken 216965120 times.
✓ Branch 2 taken 103224320 times.
✓ Branch 3 taken 103224320 times.
423413760 if((j<i)&&(j&1))
4877 {
4878 103224320 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4879 103224320 }
4880
4881 423413760 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4882 423413760 }
4883 1653960 }
4884
4885 9845 advanceframe(true);
4886
4887 // animate_combos();
4888
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9844 times.
9845 if(Quit)
4889 1 break;
4890 9844 }
4891
4892 235 destroy_bitmap(wavebuf);
4893 235 }
4894
4895 232 void wavyin()
4896 {
4897 232 draw_screen(tmpscr);
4898 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4899
4900 232 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4901 232 clear_to_color(wavebuf,0);
4902 232 blit(framebuf,wavebuf,0,0,16,0,256,224);
4903
4904 static PALETTE wavepal;
4905
4906 //Breaks dark rooms.
4907 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4908 /*
4909 loadfullpal();
4910 loadlvlpal(DMaps[currdmap].color);
4911 ringcolor(false);
4912 */
4913 232 refreshpal=false;
4914 int32_t ofs;
4915 232 int32_t amplitude=8;
4916 232 int32_t wavelength=4;
4917 232 double palpos=168, palstep=4, palstop=126;
4918
4919 232 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4920
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 9703 times.
9934 for(int32_t i=0; i<168; i+=wavelength)
4921 {
4922
2/2
✓ Branch 0 taken 2483968 times.
✓ Branch 1 taken 9703 times.
2493671 for(int32_t l=0; l<256; l++)
4923 {
4924 2483968 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4925 2483968 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4926 2483968 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4927 2483968 }
4928
4929 9703 palpos-=palstep;
4930
4931
1/2
✓ Branch 0 taken 9703 times.
✗ Branch 1 not taken.
9703 if(palpos>=0)
4932 {
4933 9703 hw_palette = &wavepal;
4934 9703 update_hw_pal = true;
4935 9703 }
4936 else
4937 {
4938 hw_palette = &RAMpal;
4939 update_hw_pal = true;
4940 }
4941
4942
2/2
✓ Branch 0 taken 1630104 times.
✓ Branch 1 taken 9703 times.
1639807 for(int32_t j=0; j+playing_field_offset<224; j++)
4943 {
4944
2/2
✓ Branch 0 taken 417306624 times.
✓ Branch 1 taken 1630104 times.
418936728 for(int32_t k=0; k<256; k++)
4945 {
4946 417306624 ofs=0;
4947
4948
4/4
✓ Branch 0 taken 211158272 times.
✓ Branch 1 taken 206148352 times.
✓ Branch 2 taken 106821120 times.
✓ Branch 3 taken 104337152 times.
417306624 if((j<(167-i))&&(j&1))
4949 {
4950 104337152 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4951 104337152 }
4952
4953 417306624 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4954 417306624 }
4955 1630104 }
4956
4957 9703 advanceframe(true);
4958 // animate_combos();
4959
4960
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9702 times.
9703 if(Quit)
4961 1 break;
4962 9702 }
4963
4964 232 destroy_bitmap(wavebuf);
4965 232 }
4966
4967 4332 void blackscr(int32_t fcnt,bool showsubscr)
4968 {
4969 4332 reset_pal_cycling();
4970 4332 script_drawing_commands.Clear();
4971
4972 4332 FFCore.warpScriptCheck();
4973 4332 bool showtime = game->should_show_time();
4974
2/2
✓ Branch 0 taken 4325 times.
✓ Branch 1 taken 129517 times.
133842 while(fcnt>0)
4975 {
4976 129517 clear_bitmap(framebuf);
4977
4978
2/2
✓ Branch 0 taken 59250 times.
✓ Branch 1 taken 70267 times.
129517 if(showsubscr)
4979 {
4980 70267 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4981
3/4
✓ Branch 0 taken 70267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✓ Branch 3 taken 69037 times.
70267 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4982 {
4983 1230 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4984 1230 }
4985 70267 }
4986
4987 129517 advanceframe(true);
4988
4989
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 129510 times.
129517 if(Quit)
4990 7 break;
4991
4992 129510 --fcnt;
4993 }
4994 4332 }
4995
4996 2670 void openscreen(int32_t shape)
4997 {
4998 2670 reset_pal_cycling();
4999 2670 black_opening_count=0;
5000
5001
3/4
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 2148 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522 times.
2670 if(COOLSCROLL || shape>-1)
5002 {
5003 2148 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5004 2148 return;
5005 }
5006 else
5007 {
5008 522 Hero.setDontDraw(true);
5009 522 show_subscreen_dmap_dots=false;
5010 522 show_subscreen_numbers=false;
5011 522 show_subscreen_life=false;
5012 }
5013
5014 522 int32_t x=128;
5015
5016 522 FFCore.warpScriptCheck();
5017
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 41760 times.
42282 for(int32_t i=0; i<80; i++)
5018 {
5019 41760 draw_screen(tmpscr);
5020 //? draw_screen already draws the subscreen -DD
5021 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5022 41760 x=128-(((i*128/80)/8)*8);
5023
5024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(x>0)
5025 {
5026 41760 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5027 41760 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5028 41760 }
5029
5030 41760 advanceframe(true);
5031
5032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(Quit)
5033 {
5034 break;
5035 }
5036 41760 }
5037
5038 522 Hero.setDontDraw(false);
5039 522 show_subscreen_items=true;
5040 522 show_subscreen_dmap_dots=true;
5041 522 show_subscreen_numbers=true;
5042 522 show_subscreen_life=true;
5043 2670 }
5044
5045 4 void closescreen(int32_t shape)
5046 {
5047 4 reset_pal_cycling();
5048 4 black_opening_count=0;
5049
5050
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(COOLSCROLL || shape>-1)
5051 {
5052 4 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5053 4 return;
5054 }
5055 else
5056 {
5057 Hero.setDontDraw(true);
5058 show_subscreen_dmap_dots=false;
5059 show_subscreen_numbers=false;
5060 // show_subscreen_items=false;
5061 show_subscreen_life=false;
5062 }
5063
5064 int32_t x=128;
5065
5066 FFCore.warpScriptCheck();
5067 for(int32_t i=79; i>=0; --i)
5068 {
5069 draw_screen(tmpscr);
5070 //? draw_screen already draws the subscreen -DD
5071 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5072 x=128-(((i*128/80)/8)*8);
5073
5074 if(x>0)
5075 {
5076 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5077 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5078 }
5079
5080 advanceframe(true);
5081
5082 if(Quit)
5083 {
5084 break;
5085 }
5086 }
5087
5088 Hero.setDontDraw(false);
5089 show_subscreen_items=true;
5090 show_subscreen_dmap_dots=true;
5091 4 }
5092
5093 296 int32_t TriforceCount()
5094 {
5095 296 int32_t c=0;
5096
5097
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 296 times.
2664 for(int32_t i=1; i<=8; i++)
5098
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1884 times.
4252 if(game->lvlitems[i]&liTRIFORCE)
5099 1884 ++c;
5100
5101 296 return c;
5102 }
5103
5104 int32_t onCustomGame()
5105 {
5106 int32_t file = getsaveslot();
5107
5108 if(file < 0)
5109 return D_O_K;
5110
5111 bool ret = (custom_game(file)!=0);
5112 return ret ? D_CLOSE : D_O_K;
5113 }
5114
5115 int32_t onContinue()
5116 {
5117 return D_CLOSE;
5118 }
5119
5120 int32_t onEsc() // Unused?? -L
5121 {
5122 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5123 }
5124
5125 int32_t onThrottleFPS()
5126 {
5127 Throttlefps = !Throttlefps;
5128 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5129 return D_O_K;
5130 }
5131
5132 int32_t onWinPosSave()
5133 {
5134 SaveWinPos = !SaveWinPos;
5135 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5136 return D_O_K;
5137 }
5138 int32_t onIntegerScaling()
5139 {
5140 scaleForceInteger = !scaleForceInteger;
5141 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5142 return D_O_K;
5143 }
5144 int32_t onStretchGame()
5145 {
5146 stretchGame = !stretchGame;
5147 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5148 return D_O_K;
5149 }
5150
5151 int32_t onClickToFreeze()
5152 {
5153 ClickToFreeze = !ClickToFreeze;
5154 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5155 return D_O_K;
5156 }
5157
5158 int32_t OnSaveZCConfig()
5159 {
5160 if(jwin_alert3(
5161 "Save Configuration",
5162 "Are you sure that you wish to save your present configuration settings?",
5163 "This will overwrite your prior settings!",
5164 NULL,
5165 "&Yes",
5166 "&No",
5167 NULL,
5168 'y',
5169 'n',
5170 0,
5171 get_zc_font(font_lfont)) == 1)
5172 {
5173 save_game_configs();
5174 return D_O_K;
5175 }
5176 else return D_O_K;
5177 }
5178
5179 int32_t OnnClearQuestDir()
5180 {
5181 auto current_path = fs::current_path() / "quests";
5182 if(jwin_alert3(
5183 "Clear Current Directory Cache",
5184 "Are you sure that you wish to reset where ZC Player looks for quests?",
5185 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
5186 NULL,
5187 "&Yes",
5188 "&No",
5189 NULL,
5190 'y',
5191 'n',
5192 0,
5193 get_zc_font(font_lfont)) == 1)
5194 {
5195 zc_set_config("zeldadx","quest_dir","quests");
5196 flush_config_file();
5197 strcpy(qstdir,"quests");
5198 #ifdef __EMSCRIPTEN__
5199 em_sync_fs();
5200 #endif
5201 return D_O_K;
5202 }
5203 else return D_O_K;
5204 }
5205
5206 int32_t onConsole()
5207 {
5208 if ( !console_enabled )
5209 {
5210 AlertDialog("ZC Console",
5211 "Open the ZC Console?"
5212 "\nThis will display any messages logged by scripts,"
5213 " including errors.",
5214 [&](bool ret,bool)
5215 {
5216 if(ret)
5217 {
5218 FFCore.ZScriptConsole(true);
5219 }
5220 }).show();
5221 return D_O_K;
5222 }
5223 else
5224 {
5225 FFCore.ZScriptConsole(false);
5226 return D_O_K;
5227 }
5228 }
5229
5230 int32_t onClrConsoleOnReload()
5231 {
5232 clearConsoleOnReload = !clearConsoleOnReload;
5233 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5234 return D_O_K;
5235 }
5236 int32_t onClrConsoleOnLoad()
5237 {
5238 clearConsoleOnLoad = !clearConsoleOnLoad;
5239 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5240 return D_O_K;
5241 }
5242
5243
5244 int32_t onFrameSkip()
5245 {
5246 FrameSkip = !FrameSkip;
5247 return D_O_K;
5248 }
5249
5250 int32_t onSaveDragResize()
5251 {
5252 SaveDragResize = !SaveDragResize;
5253 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5254 return D_O_K;
5255 }
5256
5257 int32_t onDragAspect()
5258 {
5259 DragAspect = !DragAspect;
5260 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5261 return D_O_K;
5262 }
5263
5264 int32_t onTransLayers()
5265 {
5266 TransLayers = !TransLayers;
5267 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5268 return D_O_K;
5269 }
5270
5271 int32_t onNESquit()
5272 {
5273 NESquit = !NESquit;
5274 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5275 return D_O_K;
5276 }
5277
5278 int32_t onVolKeys()
5279 {
5280 volkeys = !volkeys;
5281 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5282 return D_O_K;
5283 }
5284
5285 int32_t onShowFPS()
5286 {
5287 ShowFPS = !ShowFPS;
5288 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5289 return D_O_K;
5290 }
5291
5292 int32_t onShowTime()
5293 {
5294 ShowGameTime = !ShowGameTime;
5295 zc_set_config(cfg_sect,"showtime",ShowGameTime);
5296 return D_O_K;
5297 }
5298
5299 2162645118 bool is_Fkey(int32_t k)
5300 {
5301
2/2
✓ Branch 0 taken 219930012 times.
✓ Branch 1 taken 1942715106 times.
2162645118 switch(k)
5302 {
5303 case KEY_F1:
5304 case KEY_F2:
5305 case KEY_F3:
5306 case KEY_F4:
5307 case KEY_F5:
5308 case KEY_F6:
5309 case KEY_F7:
5310 case KEY_F8:
5311 case KEY_F9:
5312 case KEY_F10:
5313 case KEY_F11:
5314 case KEY_F12:
5315 219930012 return true;
5316 }
5317
5318 1942715106 return false;
5319 2162645118 }
5320
5321 void kb_getkey(DIALOG *d);
5322
5323 //Used by all keyboard key settings dialogues.
5324 void kb_clearjoystick(DIALOG *d)
5325 {
5326 d->flags|=D_SELECTED;
5327
5328 jwin_button_proc(MSG_DRAW,d,0);
5329 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5330 // text_mode(vc(11));
5331 textout_centre_ex(screen, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5332 textout_centre_ex(screen, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5333
5334 update_hw_screen();
5335
5336 clear_keybuf();
5337 int32_t k = next_press_key();
5338 clear_keybuf();
5339
5340 //shnarf
5341 //47=f1
5342 //59=esc
5343 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5344 // *((int32_t*)d->dp3) = k;
5345 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5346
5347
5348 d->flags&=~D_SELECTED;
5349 }
5350
5351 //Clears key to 0.
5352 //Used by all keyboard key settings dialogues.
5353 void kb_clearkey(DIALOG *d);
5354
5355 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5356 {
5357 switch(msg)
5358 {
5359 case MSG_KEY:
5360 case MSG_CLICK:
5361
5362 kb_clearjoystick(d);
5363
5364 while(gui_mouse_b())
5365 {
5366 clear_keybuf();
5367 rest(1);
5368 }
5369
5370 return D_REDRAW;
5371 }
5372
5373 return jwin_button_proc(msg,d,c);
5374 }
5375
5376 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5377 //Only used in keyboard settings dialogues to clear keys.
5378 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5379
5380 int32_t j_getbtn(DIALOG *d)
5381 {
5382 d->flags|=D_SELECTED;
5383 jwin_button_proc(MSG_DRAW,d,0);
5384 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5385 // text_mode(vc(11));
5386 int32_t y = screen->h/2 - 12;
5387 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5388 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5389 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5390
5391 update_hw_screen();
5392
5393 int32_t b = next_joy_input(true);
5394 if (b == -2)
5395 return D_CLOSE;
5396
5397 if(b>=0)
5398 *((int32_t*)d->dp3) = b;
5399
5400 d->flags&=~D_SELECTED;
5401
5402 return D_O_K;
5403 }
5404
5405 void j_getstick(DIALOG *d)
5406 {
5407 d->flags|=D_SELECTED;
5408 jwin_button_proc(MSG_DRAW,d,0);
5409 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5410 // text_mode(vc(11));
5411 int32_t y = screen->h/2 - 12;
5412 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5413 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5414 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5415
5416 update_hw_screen();
5417
5418 int32_t b = next_joy_input(false);
5419
5420 if(b>=0)
5421 *((int32_t*)d->dp3) = b;
5422
5423 d->flags&=~D_SELECTED;
5424 }
5425
5426 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5427 {
5428 switch(msg)
5429 {
5430 case MSG_KEY:
5431 case MSG_CLICK:
5432
5433 int ret = j_getbtn(d);
5434 if (ret != D_O_K)
5435 return ret;
5436
5437 while(gui_mouse_b()) {
5438 rest(1);
5439 clear_keybuf();
5440 }
5441
5442 return D_REDRAW;
5443 }
5444
5445 return jwin_button_proc(msg,d,c);
5446 }
5447
5448 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5449 {
5450 switch(msg)
5451 {
5452 case MSG_KEY:
5453 case MSG_CLICK:
5454
5455 j_getstick(d);
5456
5457 while(gui_mouse_b()) {
5458 rest(1);
5459 clear_keybuf();
5460 }
5461
5462 return D_REDRAW;
5463 }
5464
5465 return jwin_button_proc(msg,d,c);
5466 }
5467
5468 //shnarf
5469 extern const char *key_str[];
5470 std::string get_keystr(int key);
5471
5472 const char *pan_str[4] = { " MONO", " 1/2", " 3/4", " FULL" };
5473
5474 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5475 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5476 str_primary_stick[80], str_secondary_stick[80];
5477
5478 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5479 {
5480 //these are here to bypass compiler warnings about unused arguments
5481 c=c;
5482
5483 if (d->w == 1)
5484 {
5485 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5486 {
5487 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5488 return D_CLOSE;
5489 }
5490 }
5491
5492 if(msg==MSG_DRAW)
5493 {
5494 switch(d->w)
5495 {
5496 case 0:
5497 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5498 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5499 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5500 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5501 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5502 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5503 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5504 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5505 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5506 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5507 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5508 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5509 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5510 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5511 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5512 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5513 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5514 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5515 break;
5516
5517 case 1:
5518 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5519 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5520 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5521 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5522 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5523 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5524 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5525 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5526 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5527 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5528 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5529 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5530 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5531 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5532 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5533 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5534 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5535 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5536 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5537 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5538 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5539 break;
5540
5541 case 2:
5542 sprintf(str_a," %3d",midi_volume);
5543 sprintf(str_l," %3d",emusic_volume);
5544 sprintf(str_r," %3d",sfx_volume);
5545 strcpy(str_s,pan_str[pan_style]);
5546 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5547 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5548 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5549 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5550 break;
5551 }
5552 }
5553
5554 return D_O_K;
5555 }
5556
5557 int32_t set_vol(void *dp3, int32_t d2)
5558 {
5559 switch(((int32_t*)dp3)[0])
5560 {
5561 case 0:
5562 midi_volume = zc_min(d2<<3,255);
5563 break;
5564
5565 case 1:
5566 digi_volume = zc_min(d2<<3,255);
5567 break;
5568
5569 case 2:
5570 emusic_volume = zc_min(d2<<3,255);
5571 break;
5572
5573 case 3:
5574 sfx_volume = zc_min(d2<<3,255);
5575 break;
5576 }
5577
5578 // text_mode(vc(11));
5579 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]," %3d",zc_min(d2<<3,255));
5580 return D_O_K;
5581 }
5582
5583 int32_t set_pan(void *dp3, int32_t d2)
5584 {
5585 pan_style = vbound(d2,0,3);
5586 // text_mode(vc(11));
5587 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5588 return D_O_K;
5589 }
5590
5591 static int32_t gamepad_joys_list[] =
5592 {
5593 61,
5594 -1
5595 };
5596
5597 static int32_t gamepad_btn_list[] =
5598 {
5599 6,
5600 7,8,9,10,11,12,13,14,15,16,17,
5601 18,19,20,21,22,23,24,25,26,27,28,
5602 29,30,31,32,33,34,35,36,37,38,39,
5603 -1
5604 };
5605
5606 static int32_t gamepad_dirs_list[] =
5607 {
5608 40,41,42,43,
5609 44,45,46,47,
5610 48,49,50,51,
5611 52,53,54,55,
5612 56,57,58,59,
5613 60,
5614 -1
5615 };
5616
5617 static TABPANEL gamepad_tabs[] =
5618 {
5619 // (text)
5620 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5621 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5622 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5623 { NULL, 0, NULL, 0, NULL }
5624 };
5625
5626 const char *joy_list(int32_t index, int32_t *list_size)
5627 {
5628 if (index == -1)
5629 {
5630 *list_size = al_get_num_joysticks();
5631 return NULL;
5632 }
5633
5634 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5635 if (!joy)
5636 {
5637 return "?";
5638 }
5639
5640 return al_get_joystick_name(joy);
5641 }
5642
5643 355 static ListData joy__list(joy_list, &font);
5644
5645 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5646 {
5647 int32_t d2 = d->d2;
5648 int32_t ret = jwin_droplist_proc(msg,d,c);
5649
5650 if(d2!=d->d2)
5651 {
5652 joystick_index = d->d2;
5653 ret |= D_REDRAW_ALL;
5654 }
5655
5656 return ret;
5657 }
5658
5659 static DIALOG gamepad_dlg[] =
5660 {
5661 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5662 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5663 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5664 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5665 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5666 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5667 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5668 // 6
5669 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5670 // 7
5671 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5672 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5673 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5674 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5675 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5676 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5677 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5678 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5679 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5680 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5681 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5682 // 18
5683 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5684 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5685 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5686 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5687 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5688 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5689 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5690 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5691 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5692 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5693 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5694 // 29
5695 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5696 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5697 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5698 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5699 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5700 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5701 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5702 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5703 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5704 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5705 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5706 // 40
5707 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5708 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5709 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5710 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5711 // 44
5712 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5713 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5714 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5715 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5716 // 48
5717 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5718 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5719 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5720 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5721 // 52
5722 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5723 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5724 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5725 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5726 // 56
5727 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5728 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5729 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5730 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5731 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5732
5733 // 61
5734 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5735
5736 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5737 };
5738
5739 static int32_t keyboard_keys_list[] =
5740 {
5741 6,7,8,9,10,
5742 11,12,13,14,15,16,17,18,19,20,
5743 21,22,23,24,25,26,27,28,29,30,
5744 31,32,33,34,35,36,37,38,39,40,
5745 -1
5746 };
5747
5748 static int32_t keyboard_dirs_list[] =
5749 {
5750 41,42,43,44,
5751 45,46,47,48,
5752 49,50,51,52,
5753 53,54,55,56,
5754 -1
5755 };
5756
5757 static int32_t keyboard_mods_list[] =
5758 {
5759 57,58,59,60,
5760 61,62,63,64,
5761 65,66,67,68,
5762 69,70,71,72,
5763 -1
5764 };
5765
5766 static TABPANEL keyboard_control_tabs[] =
5767 {
5768 // (text)
5769 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5770 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5771 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5772 { NULL, 0, NULL, 0, NULL }
5773 };
5774
5775 static DIALOG keyboard_control_dlg[] =
5776 {
5777 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5778 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5779 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5780 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5781 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5782 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5783 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5784 // Keys
5785 // 6
5786 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5788 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5789 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5790 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5791 // 11
5792 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5793 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5794 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5795 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5796 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5797 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5798 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5799 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5800 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5801 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5802 // 21
5803 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5804 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5805 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5806 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5807 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5808 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5809 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5810 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5811 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5812 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5813 // 31
5814 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5815 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5816 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5817 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5818 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5819 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5820 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5821 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5822 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5823 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5824 // Dirs
5825 // 41
5826 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5827 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5828 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5829 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5830 // 45
5831 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5832 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5833 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5834 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5835 // 49
5836 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5837 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5838 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5839 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5840 // 53
5841 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5842 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5843 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5844 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5845 // Mods
5846 // 57
5847 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5848 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5849 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5850 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5851 // 61
5852 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5853 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5854 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5855 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5856 // 65
5857 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5858 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5859 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5860 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5861 // 69
5862 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5863 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5864 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5865 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5866 // 73
5867 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5868 };
5869
5870 int32_t midi_dp[3] = {0,0,0};
5871 int32_t emus_dp[3] = {2,0,0};
5872 int32_t sfx_dp[3] = {3,0,0};
5873 int32_t pan_dp[3] = {0,0,0};
5874
5875 static DIALOG sound_dlg[] =
5876 {
5877 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5878 355 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5879 355 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5880 355 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5881 355 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5882 355 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5883 355 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5884 355 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5885 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5886 355 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5887 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5888 // 10
5889 355 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5890 355 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5891 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5892 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5893 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5894 355 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5895 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5896 355 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5897 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 355 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5899 //20
5900 355 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5901 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5902 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5903 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5904 355 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "MIDI Volume", NULL, NULL },
5905 355 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Music Volume (Enhanced Music)", NULL, NULL },
5906 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5907 355 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5908 355 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5909 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5910 //30
5911 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 355 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5913 355 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5914 };
5915
5916 char zc_builddate[80];
5917 char zc_aboutstr[80];
5918
5919 static DIALOG about_dlg[] =
5920 {
5921 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5922 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5923 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5924 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5925 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5926 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5927 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5928 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5929 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5930 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5931 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5932 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5934 };
5935
5936
5937 static DIALOG quest_dlg[] =
5938 {
5939 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5940 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5941 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5942 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5943 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5944 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5945 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5946 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5947 { jwin_text_proc, 130, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5948 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5949 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5950 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5951 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5952 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5953 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5954 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5955 };
5956
5957 static DIALOG triforce_dlg[] =
5958 {
5959 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5960 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5961 // 1
5962 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5963 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5964 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5965 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5966 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5967 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5968 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5969 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5970 // 9
5971 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5972 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5973 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5974 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5975 };
5976
5977 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5978 {
5979 go();
5980 int32_t ret=0;
5981 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5982 comeback();
5983 return ret != 0;
5984 }
5985
5986
5987 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5988 {
5989 if(def!=modulepath)
5990 strcpy(modulepath,def);
5991
5992 if(!usefilename)
5993 {
5994 int32_t i=(int32_t)strlen(modulepath);
5995
5996 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5997 modulepath[i--]=0;
5998 }
5999
6000 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6001 int32_t ret=0;
6002 int32_t sel=0;
6003
6004 if(list==NULL)
6005 {
6006 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6007 }
6008 else
6009 {
6010 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6011 }
6012
6013 return ret!=0;
6014 }
6015
6016 int32_t onToggleRecordingNewSaves()
6017 {
6018 if (zc_get_config("zeldadx", "replay_new_saves", false))
6019 {
6020 zc_set_config("zeldadx", "replay_new_saves", false);
6021 }
6022 else
6023 {
6024 zc_set_config("zeldadx", "replay_new_saves", true);
6025 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6026 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6027 }
6028 return D_O_K;
6029 }
6030
6031 int32_t onToggleSnapshotAllFrames()
6032 {
6033 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6034 return D_O_K;
6035 }
6036
6037 int32_t onStopReplayOrRecord()
6038 {
6039 if (replay_is_replaying())
6040 {
6041 replay_quit();
6042 }
6043 else if (replay_get_mode() == ReplayMode::Record)
6044 {
6045 if (!replay_get_meta_bool("test_mode"))
6046 {
6047 jwin_alert("Recording", "You cannot stop recording a save file.",
6048 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6049 return D_CLOSE;
6050 }
6051
6052 if (jwin_alert("Stop Recording",
6053 "Save replay to disk and stop recording?",
6054 "This will stop the recording.",
6055 NULL,
6056 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6057 return D_CLOSE;
6058
6059 replay_save();
6060 replay_stop();
6061 }
6062 return D_O_K;
6063 }
6064
6065 static int32_t handle_on_load_replay(ReplayMode mode)
6066 {
6067 bool ctrl = CHECK_CTRL_CMD;
6068 if (Playing)
6069 {
6070 if (jwin_alert("Replay - Warning!",
6071 "Loading a replay will exit the current game.",
6072 "All unsaved progress will be lost.",
6073 "Do you wish to continue?",
6074 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6075 return D_CLOSE;
6076 }
6077
6078 std::string mode_string = replay_mode_to_string(mode);
6079 mode_string[0] = std::toupper(mode_string[0]);
6080
6081 std::string line_1 = "Select a replay file to play back.";
6082 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6083 std::string line_3 = "You can stop the replay and take over manually any time.";
6084 if (mode == ReplayMode::Update)
6085 {
6086 line_1 = "Select a replay file to update.";
6087 line_2 = "WARNING: be sure to back up the zplay file";
6088 line_3 = "and verify that the updated replay works as expected!";
6089 }
6090
6091 if (jwin_alert(mode_string.c_str(),
6092 line_1.c_str(),
6093 line_2.c_str(),
6094 line_3.c_str(),
6095 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6096 {
6097 char replay_path[2048];
6098 strcpy(replay_path, "replays/");
6099 if(ctrl && devpwd())
6100 strcpy(replay_path, "../../tests/replays");
6101 if (jwin_file_select_ex(
6102 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6103 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6104 return D_CLOSE;
6105
6106 replay_quit();
6107 load_replay_file_deferred(mode, replay_path);
6108 Quit = qRESET;
6109 return D_CLOSE;
6110 }
6111 return D_O_K;
6112 }
6113
6114 int32_t onLoadReplay()
6115 {
6116 return handle_on_load_replay(ReplayMode::Replay);
6117 }
6118
6119 int32_t onLoadReplayAssert()
6120 {
6121 return handle_on_load_replay(ReplayMode::Assert);
6122 }
6123
6124 int32_t onLoadReplayUpdate()
6125 {
6126 return handle_on_load_replay(ReplayMode::Update);
6127 }
6128
6129 int32_t onSaveReplay()
6130 {
6131 if (replay_get_mode() == ReplayMode::Record)
6132 {
6133 if (!replay_get_meta_bool("test_mode"))
6134 {
6135 if (jwin_alert("Save Replay",
6136 "This will save a copy of the replay up to this point.",
6137 "The official replay file will be untouched.",
6138 "Do you wish to continue?",
6139 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6140 return D_CLOSE;
6141
6142 char replay_path[2048];
6143 strcpy(replay_path, replay_get_replay_path().string().c_str());
6144 if (jwin_file_select_ex(
6145 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6146 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6147 return D_CLOSE;
6148
6149 if (fileexists(replay_path))
6150 {
6151 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6152 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6153 return D_CLOSE;
6154 }
6155
6156 replay_save(replay_path);
6157 }
6158 else
6159 {
6160 replay_save();
6161 }
6162 }
6163 return D_O_K;
6164 }
6165
6166 enum
6167 {
6168 MENUID_REPLAY_RECORDNEW,
6169 MENUID_REPLAY_STOP,
6170 MENUID_REPLAY_SAVE,
6171 MENUID_REPLAY_SNAP_ALL,
6172 };
6173
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu replay_menu
6174 2840 {
6175
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Record new saves", onToggleRecordingNewSaves, MENUID_REPLAY_RECORDNEW },
6176
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Stop replay", onStopReplayOrRecord, MENUID_REPLAY_STOP },
6177
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Load replay", onLoadReplay },
6178
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Load replay (assert)", onLoadReplayAssert },
6179
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Load replay (update)", onLoadReplayUpdate },
6180
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Save replay", onSaveReplay, MENUID_REPLAY_SAVE },
6181
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Snapshot all frames", onToggleSnapshotAllFrames, MENUID_REPLAY_SNAP_ALL },
6182 };
6183
6184 static DIALOG credits_dlg[] =
6185 {
6186 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6187 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6188 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6189 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6190 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6191 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6192 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6193 };
6194
6195 355 static ListData dmap_list(dmaplist, &font);
6196
6197 static DIALOG goto_dlg[] =
6198 {
6199 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6200 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6201 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6202 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6203 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6204 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6205 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6206 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6207 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6208 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6209 };
6210
6211 int32_t onGoTo()
6212 {
6213 bool music = false;
6214 music = music;
6215 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6216
6217 goto_dlg[0].dp2=get_zc_font(font_lfont);
6218 goto_dlg[4].d2=cheat_goto_dmap;
6219 goto_dlg[6].dp=cheat_goto_screen_str;
6220
6221 clear_keybuf();
6222
6223 large_dialog(goto_dlg);
6224
6225 if(do_zqdialog(goto_dlg,4)==1)
6226 {
6227 // dmap, screen
6228 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6229 };
6230
6231 return D_O_K;
6232 }
6233
6234 int32_t onGoToComplete()
6235 {
6236 if(!Playing)
6237 {
6238 return D_O_K;
6239 }
6240
6241 enter_sys_pal();
6242 music_pause();
6243 pause_all_sfx();
6244 onGoTo();
6245 eat_buttons();
6246
6247 zc_readrawkey(KEY_ESC);
6248
6249 exit_sys_pal();
6250 music_resume();
6251 resume_all_sfx();
6252 return D_O_K;
6253 }
6254
6255 int32_t onCredits()
6256 {
6257 return D_O_K;
6258 }
6259
6260 const char *midilist(int32_t index, int32_t *list_size)
6261 {
6262 if(index<0)
6263 {
6264 *list_size=0;
6265
6266 for(int32_t i=0; i<MAXMIDIS; i++)
6267 if(tunes[i].data)
6268 ++(*list_size);
6269
6270 return NULL;
6271 }
6272
6273 int32_t i=0,m=0;
6274
6275 while(m<=index && i<=MAXMIDIS)
6276 {
6277 if(tunes[i].data)
6278 ++m;
6279
6280 ++i;
6281 }
6282
6283 --i;
6284
6285 if(i==MAXMIDIS && m<index)
6286 return "(null)";
6287
6288 return tunes[i].title;
6289 }
6290
6291 /* ------- MIDI info stuff -------- */
6292
6293 char *text;
6294 midi_info *zmi;
6295 bool dialog_running;
6296 bool listening;
6297
6298 void get_info(int32_t index);
6299
6300 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6301 {
6302 int32_t d2 = d->d2;
6303 int32_t ret = jwin_droplist_proc(msg,d,c);
6304
6305 if(d2!=d->d2)
6306 {
6307 get_info(d->d2);
6308 }
6309
6310 return ret;
6311 }
6312
6313 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6314 {
6315 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6316
6317 int32_t ret = jwin_button_proc(msg,d,c);
6318
6319 if(ret == D_CLOSE)
6320 {
6321 // get current midi index
6322 int32_t index = (d+(d->d1))->d2;
6323 int32_t i=0, m=0;
6324
6325 while(m<=index && i<=MAXMIDIS)
6326 {
6327 if(tunes[i].data)
6328 ++m;
6329
6330 ++i;
6331 }
6332
6333 --i;
6334 jukebox(i);
6335 listening = true;
6336 ret = D_O_K;
6337 }
6338
6339 return ret;
6340 }
6341
6342 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6343 {
6344 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6345
6346 int32_t ret = jwin_button_proc(msg,d,c);
6347
6348 if(ret == D_CLOSE)
6349 {
6350 // get current midi index
6351 int32_t index = (d+(d->d1))->d2;
6352 int32_t i=0, m=0;
6353
6354 while(m<=index && i<=MAXMIDIS)
6355 {
6356 if(tunes[i].data)
6357 ++m;
6358
6359 ++i;
6360 }
6361
6362 --i;
6363
6364 // get file name
6365
6366 int32_t sel=0;
6367 //struct ffblk f;
6368 char title[40] = "Save MIDI: ";
6369 char fname[2048];
6370 memset(fname,0,2048);
6371 static EXT_LIST list[] =
6372 {
6373 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6374 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6375 { NULL, NULL }
6376 };
6377
6378 strcpy(title+11, tunes[i].title);
6379 title[39] = '\0';
6380
6381 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6382 goto done;
6383
6384 if(exists(fname))
6385 {
6386 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6387 goto done;
6388 }
6389
6390 // save midi i
6391
6392 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6393 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6394
6395 done:
6396 chop_path(fname);
6397 ret = D_REDRAW;
6398 }
6399
6400 return ret;
6401 }
6402
6403 355 static ListData midi_list(midilist, &font);
6404
6405 static DIALOG midi_dlg[] =
6406 {
6407 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6408 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6409 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6410 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6411 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6412 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6413 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6414 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6415 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6416 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6417 };
6418
6419 void get_info(int32_t index)
6420 {
6421 int32_t i=0, m=0;
6422
6423 while(m<=index && i<=MAXMIDIS)
6424 {
6425 if(tunes[i].data)
6426 ++m;
6427
6428 ++i;
6429 }
6430
6431 --i;
6432
6433 if(i==MAXMIDIS && m<index)
6434 strcpy(text,"(null)");
6435 else
6436 {
6437 get_midi_info((MIDI*)tunes[i].data,zmi);
6438 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6439 }
6440
6441 midi_dlg[0].dp2=get_zc_font(font_lfont);
6442 midi_dlg[3].dp = text;
6443 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6444 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6445
6446 if(dialog_running)
6447 {
6448 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6449 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6450 }
6451 }
6452
6453 int32_t onMIDICredits()
6454 {
6455 text = (char*)malloc(4096);
6456 zmi = (midi_info*)malloc(sizeof(midi_info));
6457
6458 if(!text || !zmi)
6459 {
6460 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6461 return D_O_K;
6462 }
6463
6464 bool do_pause_midi = midi_pos >= 0 && currmidi;
6465 auto restore_midi = currmidi;
6466 if(do_pause_midi)
6467 {
6468 paused_midi_pos = midi_pos;
6469 stop_midi();
6470 midi_suspended = midissuspHALTED;
6471 }
6472
6473 midi_dlg[0].dp2=get_zc_font(font_lfont);
6474 midi_dlg[2].d1 = 0;
6475 midi_dlg[2].d2 = 0;
6476 midi_dlg[4].flags = D_EXIT;
6477 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6478
6479 listening = false;
6480 dialog_running=false;
6481 get_info(0);
6482
6483 dialog_running=true;
6484
6485 large_dialog(midi_dlg);
6486
6487 do_zqdialog(midi_dlg,0);
6488 dialog_running=false;
6489
6490 if(listening)
6491 music_stop();
6492
6493 if(do_pause_midi)
6494 {
6495 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6496 midi_suspended = midissuspRESUME;
6497 currmidi = restore_midi;
6498 midi_pos = paused_midi_pos;
6499 }
6500
6501 if(text) free(text);
6502 if(zmi) free(zmi);
6503 return D_O_K;
6504 }
6505
6506 int32_t onAbout()
6507 {
6508 char buf1[80]={0};
6509 std::ostringstream oss;
6510 sprintf(buf1,ZC_PLAYER_NAME);
6511 oss << buf1 << '\n';
6512 sprintf(buf1,"Version: %s", getVersionString());
6513 oss << buf1 << '\n';
6514 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6515 oss << buf1 << '\n';
6516 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6517 oss << buf1 << '\n';
6518
6519 InfoDialog("About ZC", oss.str()).show();
6520 return D_O_K;
6521 }
6522
6523 int32_t onQuest()
6524 {
6525 char fname[100];
6526 strcpy(fname, get_filename(qstpath));
6527 quest_dlg[0].dp2=get_zc_font(font_lfont);
6528 quest_dlg[1].dp = fname;
6529
6530 if(QHeader.quest_number==0)
6531 sprintf(str_a,"Custom");
6532 else
6533 sprintf(str_a,"%d",QHeader.quest_number);
6534
6535 sprintf(str_s,"%s",QHeader.getVerStr());
6536
6537 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6538 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6539
6540 large_dialog(quest_dlg);
6541
6542 do_zqdialog(quest_dlg, 0);
6543 return D_O_K;
6544 }
6545
6546 void call_vidmode_dlg();
6547 int32_t onVidMode()
6548 {
6549 call_vidmode_dlg();
6550 return D_O_K;
6551 }
6552
6553 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6554 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6555 //Added an extra statement, so that if the key is cleared to 0, the cleared
6556 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6557
6558 void load_ukeys(int32_t* arr)
6559 {
6560 arr[ukey_a] = Akey;
6561 arr[ukey_b] = Bkey;
6562 arr[ukey_s] = Skey;
6563 arr[ukey_l] = Lkey;
6564 arr[ukey_r] = Rkey;
6565 arr[ukey_p] = Pkey;
6566 arr[ukey_ex1] = Exkey1;
6567 arr[ukey_ex2] = Exkey2;
6568 arr[ukey_ex3] = Exkey3;
6569 arr[ukey_ex4] = Exkey4;
6570 arr[ukey_du] = DUkey;
6571 arr[ukey_dd] = DDkey;
6572 arr[ukey_dl] = DLkey;
6573 arr[ukey_dr] = DRkey;
6574 arr[ukey_mod1a] = cheat_modifier_keys[0];
6575 arr[ukey_mod1b] = cheat_modifier_keys[1];
6576 arr[ukey_mod2a] = cheat_modifier_keys[2];
6577 arr[ukey_mod2b] = cheat_modifier_keys[3];
6578 };
6579
6580 static const char* ukey_names[] = {
6581 "A", "B", "Start", "L", "R", "Map",
6582 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6583 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6584 "Cheat Mod R1", "Cheat Mod R2",
6585 };
6586 std::string get_ukey_name(int32_t k)
6587 {
6588 if (k < num_ukey) return ukey_names[k];
6589 return "";
6590 }
6591
6592 int32_t onKeyboard()
6593 {
6594 int32_t a = Akey;
6595 int32_t b = Bkey;
6596 int32_t s = Skey;
6597 int32_t l = Lkey;
6598 int32_t r = Rkey;
6599 int32_t p = Pkey;
6600 int32_t ex1 = Exkey1;
6601 int32_t ex2 = Exkey2;
6602 int32_t ex3 = Exkey3;
6603 int32_t ex4 = Exkey4;
6604 int32_t du = DUkey;
6605 int32_t dd = DDkey;
6606 int32_t dl = DLkey;
6607 int32_t dr = DRkey;
6608 int32_t mod1a = cheat_modifier_keys[0];
6609 int32_t mod1b = cheat_modifier_keys[1];
6610 int32_t mod2a = cheat_modifier_keys[2];
6611 int32_t mod2b = cheat_modifier_keys[3];
6612 bool done=false;
6613 int32_t ret;
6614
6615 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6616
6617 large_dialog(keyboard_control_dlg);
6618
6619 while(!done)
6620 {
6621 ret = do_zqdialog(keyboard_control_dlg,3);
6622
6623 if(ret==3) // OK
6624 {
6625 int32_t ukeys[num_ukey];
6626 load_ukeys(ukeys);
6627 std::vector<std::string> uniqueError;
6628 for(int32_t q = 0; q < num_ukey; ++q)
6629 {
6630 for(int32_t p = q+1; p < num_ukey; ++p)
6631 {
6632 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6633 {
6634 char buf[64];
6635 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6636 std::string str(buf);
6637 uniqueError.push_back(str);
6638 }
6639 }
6640 }
6641 if(uniqueError.size() == 0)
6642 {
6643 done = true;
6644 save_control_configs(true);
6645 }
6646 else
6647 {
6648 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6649 box_out("Cannot have duplicate keybinds!"); box_eol();
6650 for(std::vector<std::string>::iterator it = uniqueError.begin();
6651 it != uniqueError.end(); ++it)
6652 {
6653 box_out((*it).c_str()); box_eol();
6654 }
6655 box_end(true);
6656 }
6657 }
6658 else // Cancel
6659 {
6660 Akey = a;
6661 Bkey = b;
6662 Skey = s;
6663 Lkey = l;
6664 Rkey = r;
6665 Pkey = p;
6666 Exkey1 = ex1;
6667 Exkey2 = ex2;
6668 Exkey3 = ex3;
6669 Exkey4 = ex4;
6670 DUkey = du;
6671 DDkey = dd;
6672 DLkey = dl;
6673 DRkey = dr;
6674 cheat_modifier_keys[0] = mod1a;
6675 cheat_modifier_keys[1] = mod1b;
6676 cheat_modifier_keys[2] = mod2a;
6677 cheat_modifier_keys[3] = mod2b;
6678
6679 done=true;
6680 }
6681
6682 rest(1);
6683 }
6684
6685 return D_O_K;
6686 }
6687
6688 int32_t onGamepad()
6689 {
6690 if (al_get_num_joysticks() == 0)
6691 {
6692 InfoDialog("ZC", "No gamepads detected.").show();
6693 return D_O_K;
6694 }
6695
6696 int32_t a = Abtn;
6697 int32_t b = Bbtn;
6698 int32_t s = Sbtn;
6699 int32_t l = Lbtn;
6700 int32_t r = Rbtn;
6701 int32_t m = Mbtn;
6702 int32_t p = Pbtn;
6703 int32_t ex1 = Exbtn1;
6704 int32_t ex2 = Exbtn2;
6705 int32_t ex3 = Exbtn3;
6706 int32_t ex4 = Exbtn4;
6707 int32_t up = DUbtn;
6708 int32_t down = DDbtn;
6709 int32_t left = DLbtn;
6710 int32_t right = DRbtn;
6711 int32_t joy = joystick_index;
6712 int32_t stick_1 = js_stick_1_x_stick;
6713 int32_t stick_2 = js_stick_2_x_stick;
6714
6715 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6716 if(analog_movement)
6717 gamepad_dlg[56].flags|=D_SELECTED;
6718 else
6719 gamepad_dlg[56].flags&=~D_SELECTED;
6720
6721 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6722 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6723 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6724 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6725 // requires remapping every time.
6726 if (joystick_index >= al_get_num_joysticks())
6727 joystick_index = 0;
6728 gamepad_dlg[61].d2 = joystick_index;
6729
6730 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6731 if (!gamepad_dlg_cur_joystick)
6732 {
6733 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6734 return D_CLOSE;
6735 }
6736
6737 large_dialog(gamepad_dlg);
6738
6739 int32_t ret = do_zqdialog(gamepad_dlg,4);
6740
6741 if(ret == 4) //OK
6742 {
6743 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6744 joystick_index = gamepad_dlg[61].d2;
6745 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6746 if (!gamepad_dlg_cur_joystick)
6747 {
6748 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6749 return D_CLOSE;
6750 }
6751 js_stick_1_y_stick = js_stick_1_x_stick;
6752 js_stick_2_y_stick = js_stick_2_x_stick;
6753 save_control_configs(false);
6754 }
6755 else //Cancel
6756 {
6757 Abtn = a;
6758 Bbtn = b;
6759 Sbtn = s;
6760 Lbtn = l;
6761 Rbtn = r;
6762 Mbtn = m;
6763 Pbtn = p;
6764 Exbtn1 = ex1;
6765 Exbtn2 = ex2;
6766 Exbtn3 = ex3;
6767 Exbtn4 = ex4;
6768 DUbtn = up;
6769 DDbtn = down;
6770 DLbtn = left;
6771 DRbtn = right;
6772 joystick_index = joy;
6773 js_stick_1_x_stick = stick_1;
6774 js_stick_2_x_stick = stick_2;
6775 }
6776
6777 return D_O_K;
6778 }
6779
6780 int32_t onCheatKeys()
6781 {
6782 int32_t oldcheats[Cheat::Last][2];
6783 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6784
6785 bool done=false;
6786
6787 while(!done)
6788 {
6789 bool confirm = false;
6790 CheatKeysDialog(&confirm).show();
6791 if(confirm) // OK
6792 {
6793 std::vector<std::string> uniqueError;
6794 char buf[512];
6795 for(size_t q = 1; q < Cheat::Last; ++q)
6796 {
6797 if(cheatkeys[q][1] && !cheatkeys[q][0])
6798 {
6799 cheatkeys[q][0] = cheatkeys[q][1];
6800 cheatkeys[q][1] = 0;
6801 }
6802 }
6803 for(size_t q = 1; q < Cheat::Last; ++q)
6804 {
6805 if(!bindable_cheat((Cheat)q)) continue;
6806 for(size_t p = q+1; p < Cheat::Last; ++p)
6807 {
6808 if(!bindable_cheat((Cheat)p)) continue;
6809 for(size_t q2 = 0; q2 <= 1; ++q2)
6810 for(size_t p2 = 0; p2 <= 1; ++p2)
6811 {
6812 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6813 {
6814 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6815 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6816 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6817 get_keystr(cheatkeys[q][q2])));
6818 }
6819 }
6820 }
6821 }
6822 if(uniqueError.size() == 0)
6823 {
6824 done = true;
6825 save_cheatkeys();
6826 }
6827 else
6828 {
6829 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6830 box_out("Cannot have duplicate keybinds!"); box_eol();
6831 for(std::vector<std::string>::iterator it = uniqueError.begin();
6832 it != uniqueError.end(); ++it)
6833 {
6834 box_out((*it).c_str()); box_eol();
6835 }
6836 box_end(true);
6837 }
6838 }
6839 else // Cancel
6840 {
6841 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6842 done=true;
6843 }
6844 rest(1);
6845 }
6846
6847 return D_O_K;
6848 }
6849
6850 int32_t onSound()
6851 {
6852 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6853 {
6854 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6855 {
6856 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6857 }
6858 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6859 {
6860 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6861 }
6862 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6863 {
6864 emusic_volume = (int32_t)FFCore.usr_music_volume;
6865 }
6866 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6867 {
6868 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6869 }
6870 }
6871 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6872 {
6873 pan_style = (int32_t)FFCore.usr_panstyle;
6874 }
6875
6876 int32_t m = midi_volume;
6877 int32_t e = emusic_volume;
6878 int32_t s = sfx_volume;
6879 int32_t p = pan_style;
6880 pan_style = vbound(pan_style,0,3);
6881
6882 sound_dlg[0].dp2=get_zc_font(font_lfont);
6883
6884 large_dialog(sound_dlg);
6885
6886 midi_dp[1] = sound_dlg[6].x;
6887 midi_dp[2] = sound_dlg[6].y;
6888 emus_dp[1] = sound_dlg[8].x;
6889 emus_dp[2] = sound_dlg[8].y;
6890 sfx_dp[1] = sound_dlg[10].x;
6891 sfx_dp[2] = sound_dlg[10].y;
6892 pan_dp[1] = sound_dlg[11].x;
6893 pan_dp[2] = sound_dlg[11].y;
6894 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6895 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6896 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6897 sound_dlg[20].d2 = pan_style;
6898
6899 int32_t ret = do_zqdialog(sound_dlg,1);
6900
6901 if(ret==2)
6902 {
6903 master_volume(digi_volume,midi_volume);
6904 if (zcmusic)
6905 zcmusic_set_volume(zcmusic, emusic_volume);
6906
6907 int32_t temp_volume = sfx_volume;
6908 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6909 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6910 for(int32_t i=0; i<WAV_COUNT; ++i)
6911 {
6912 if(sfx_voice[i] >= 0)
6913 voice_set_volume(sfx_voice[i], temp_volume);
6914 }
6915 zc_set_config(sfx_sect,"midi",midi_volume);
6916 zc_set_config(sfx_sect,"sfx",sfx_volume);
6917 zc_set_config(sfx_sect,"emusic",emusic_volume);
6918 zc_set_config(sfx_sect,"pan",pan_style);
6919 }
6920 else
6921 {
6922 midi_volume = m;
6923 emusic_volume = e;
6924 sfx_volume = s;
6925 pan_style = p;
6926 }
6927
6928 return D_O_K;
6929 }
6930
6931 int32_t queding(char const* s1, char const* s2, char const* s3)
6932 {
6933 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6934 }
6935
6936 int32_t onQuit()
6937 {
6938 if(Playing)
6939 {
6940 int32_t ret=0;
6941
6942 if(get_qr(qr_NOCONTINUE))
6943 {
6944 if(standalone_mode)
6945 {
6946 ret=queding("End current game?",
6947 "The continue screen is disabled; the game",
6948 "will be reloaded from the last save.");
6949 }
6950 else
6951 {
6952 ret=queding("End current game?",
6953 "The continue screen is disabled. You will",
6954 "be returned to the file select screen.");
6955 }
6956 }
6957 else
6958 ret=queding("End current game?",NULL,NULL);
6959
6960 if(ret==1)
6961 {
6962 disableClickToFreeze=false;
6963 Quit=qQUIT;
6964
6965 // Trying to evade a door repair charge?
6966 if(repaircharge)
6967 {
6968 game->change_drupy(-repaircharge);
6969 repaircharge=0;
6970 }
6971
6972 return D_CLOSE;
6973 }
6974 }
6975
6976 return D_O_K;
6977 }
6978
6979 int32_t onTryQuitMenu()
6980 {
6981 return onTryQuit(true);
6982 }
6983
6984 int32_t onTryQuit(bool inMenu)
6985 {
6986 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6987 {
6988 if(active_cutscene.can_f6())
6989 {
6990 if(get_qr(qr_OLD_F6))
6991 {
6992 if(inMenu) onQuit();
6993 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
6994 }
6995 else
6996 {
6997 disableClickToFreeze=false;
6998 GameFlags |= GAMEFLAG_TRYQUIT;
6999 }
7000 return D_CLOSE;
7001 }
7002 else active_cutscene.error();
7003 }
7004
7005 return D_O_K;
7006 }
7007
7008 int32_t onReset()
7009 {
7010 if(queding(" Reset system? ",NULL,NULL)==1)
7011 {
7012 disableClickToFreeze=false;
7013 Quit=qRESET;
7014 replay_quit();
7015 return D_CLOSE;
7016 }
7017
7018 return D_O_K;
7019 }
7020
7021 int32_t onExit()
7022 {
7023 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7024 {
7025 Quit=qEXIT;
7026 return D_CLOSE;
7027 }
7028
7029 return D_O_K;
7030 }
7031
7032 int32_t onDebug()
7033 {
7034 if(debug_enabled)
7035 set_debug(!get_debug());
7036 return D_O_K;
7037 }
7038
7039 int32_t onHeartBeep()
7040 {
7041 heart_beep=!heart_beep;
7042 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7043 return D_O_K;
7044 }
7045
7046 int32_t onSaveIndicator()
7047 {
7048 use_save_indicator = use_save_indicator ? 0 : 1;
7049 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7050 return D_O_K;
7051 }
7052
7053 int32_t onEpilepsy()
7054 {
7055 if(jwin_alert3(
7056 "Epilepsy Flash Reduction",
7057 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7058 "Disabling this will restore standard flash and wavy behaviour.",
7059 "Proceed?",
7060 "&Yes",
7061 "&No",
7062 NULL,
7063 'y',
7064 'n',
7065 0,
7066 get_zc_font(font_lfont)) == 1)
7067 {
7068 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7069 zc_set_config("zeldadx","checked_epilepsy",1);
7070 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7071 }
7072 return D_O_K;
7073 }
7074
7075 bool rc = false;
7076
7077 static DIALOG getnum_dlg[] =
7078 {
7079 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7080 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7081 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7082 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7083 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7084 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7085 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7086 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7087 };
7088
7089 int32_t getnumber(const char *prompt,int32_t initialval)
7090 {
7091 char buf[20];
7092 sprintf(buf,"%d",initialval);
7093 getnum_dlg[0].dp=(void *)prompt;
7094 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7095 getnum_dlg[2].dp=buf;
7096
7097 large_dialog(getnum_dlg);
7098
7099 if(do_zqdialog(getnum_dlg,2)==3)
7100 return atoi(buf);
7101
7102 return initialval;
7103 }
7104
7105 int32_t onLife()
7106 {
7107 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7108 cheats_enqueue(Cheat::Life, value);
7109 return D_O_K;
7110 }
7111
7112 int32_t onHeartC()
7113 {
7114 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7115 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7116 cheats_enqueue(Cheat::MaxLife, max_life);
7117 cheats_enqueue(Cheat::Life, life);
7118 return D_O_K;
7119 }
7120
7121 int32_t onMagicC()
7122 {
7123 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7124 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7125 cheats_enqueue(Cheat::MaxMagic, max_magic);
7126 cheats_enqueue(Cheat::Magic, magic);
7127 return D_O_K;
7128 }
7129
7130 int32_t onRupies()
7131 {
7132 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7133 cheats_enqueue(Cheat::Rupies, value);
7134 return D_O_K;
7135 }
7136
7137 int32_t onMaxBombs()
7138 {
7139 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7140 cheats_enqueue(Cheat::MaxBombs, value);
7141 cheats_enqueue(Cheat::Bombs, value);
7142 return D_O_K;
7143 }
7144
7145 int32_t onRefillLife()
7146 {
7147 cheats_enqueue(Cheat::Life, game->get_maxlife());
7148 return D_O_K;
7149 }
7150 int32_t onRefillMagic()
7151 {
7152 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7153 return D_O_K;
7154 }
7155 int32_t onClock()
7156 {
7157 cheats_enqueue(Cheat::Clock);
7158 return D_O_K;
7159 }
7160
7161 int32_t onQstPath()
7162 {
7163 char path[2048];
7164
7165 chop_path(qstdir);
7166 strcpy(path,qstdir);
7167
7168 go();
7169
7170 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7171 {
7172 chop_path(path);
7173 fix_filename_case(path);
7174 fix_filename_slashes(path);
7175 strcpy(qstdir,path);
7176 strcpy(qstpath,qstdir);
7177 zc_set_config("zeldadx","quest_dir",qstdir);
7178 flush_config_file();
7179 }
7180
7181 comeback();
7182 return D_O_K;
7183 }
7184
7185 #include "dialog/cheat_dialog.h"
7186 int32_t onCheat()
7187 {
7188 call_setcheat_dialog();
7189 game->set_cheat(maxcheat);
7190 if(cheat) game->did_cheat(true);
7191 return D_O_K;
7192 }
7193
7194 int32_t onCheatRupies()
7195 {
7196 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7197 return D_O_K;
7198 }
7199
7200 int32_t onCheatArrows()
7201 {
7202 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7203 return D_O_K;
7204 }
7205
7206 int32_t onCheatBombs()
7207 {
7208 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7209 return D_O_K;
7210 }
7211
7212 // *** screen saver
7213
7214 18327501 int32_t after_time()
7215 {
7216
1/2
✓ Branch 0 taken 18327501 times.
✗ Branch 1 not taken.
18327501 if(ss_enable == 0)
7217 return INT_MAX;
7218
7219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
18327501 if(ss_after <= 0)
7220 return 5 * 60;
7221
7222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
18327501 if(ss_after <= 3)
7223 return ss_after * 15 * 60;
7224
7225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327501 times.
18327501 if(ss_after <= 13)
7226 return (ss_after - 3) * 60 * 60;
7227
7228 18327501 return MAX_IDLE + 1;
7229 18327501 }
7230
7231 static const char *after_str[15] =
7232 {
7233 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7234 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7235 "Never"
7236 };
7237
7238 const char *after_list(int32_t index, int32_t *list_size)
7239 {
7240 if(index < 0)
7241 {
7242 *list_size = 15;
7243 return NULL;
7244 }
7245
7246 return after_str[index];
7247 }
7248
7249 355 static ListData after__list(after_list, &font);
7250
7251 static DIALOG scrsaver_dlg[] =
7252 {
7253 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7254 355 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7255 355 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7256 355 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7257 355 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7258 355 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7259 355 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7260 355 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7261 355 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7262 355 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7263 355 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7264 355 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7265 355 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7266 355 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7267 };
7268
7269 int32_t onScreenSaver()
7270 {
7271 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7272 int32_t oldcfgs[3];
7273 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7274 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7275 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7276
7277 large_dialog(scrsaver_dlg);
7278
7279 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7280
7281 if(ret == 8 || ret == 9)
7282 {
7283 ss_after = scrsaver_dlg[5].d1;
7284 ss_speed = scrsaver_dlg[6].d2;
7285 ss_density = scrsaver_dlg[7].d2;
7286 if(oldcfgs[0] != ss_after)
7287 zc_set_config(cfg_sect,"ss_after",ss_after);
7288 if(oldcfgs[1] != ss_speed)
7289 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7290 if(oldcfgs[2] != ss_density)
7291 zc_set_config(cfg_sect,"ss_density",ss_density);
7292 }
7293
7294 if(ret == 9)
7295 // preview Screen Saver
7296 {
7297 clear_keybuf();
7298 Matrix(ss_speed, ss_density, 30);
7299 system_pal(true);
7300 sys_mouse();
7301 }
7302
7303 return D_O_K;
7304 }
7305
7306 /***** Menus *****/
7307
7308 enum
7309 {
7310 MENUID_GAME_LOADQUEST,
7311 MENUID_GAME_ENDGAME,
7312 };
7313
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu game_menu
7314 2840 {
7315
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "&Continue","ESC", onContinue },
7316
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7317
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "L&oad Quest...", onCustomGame, MENUID_GAME_LOADQUEST },
7318
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "&End Game","F6", onTryQuitMenu, MENUID_GAME_ENDGAME },
7319
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7320 #ifdef __EMSCRIPTEN__
7321 { "&Reset","F7", onReset },
7322 #elif defined(ALLEGRO_MACOSX)
7323 { "&Reset","F7", onReset },
7324 { "&Quit","F8", onExit },
7325 #else
7326
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "&Reset","F9", onReset },
7327
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "&Quit","F10", onExit },
7328 #endif
7329 };
7330
7331
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu snapshot_format_menu
7332 2485 {
7333
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "&BMP", std::bind(onSetSnapshotFormat, ssfmtBMP) },
7334
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "&GIF", std::bind(onSetSnapshotFormat, ssfmtGIF) },
7335
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "&JPG", std::bind(onSetSnapshotFormat, ssfmtJPG) },
7336
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "&PNG", std::bind(onSetSnapshotFormat, ssfmtPNG) },
7337
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "PC&X", std::bind(onSetSnapshotFormat, ssfmtPCX) },
7338
4/8
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 355 times.
✗ Branch 7 not taken.
355 { "&TGA", std::bind(onSetSnapshotFormat, ssfmtTGA) },
7339 };
7340
7341
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu controls_menu
7342 1420 {
7343
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Key&board...", onKeyboard },
7344
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Gamepad...", onGamepad },
7345
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Cheat Keys...", onCheatKeys },
7346 };
7347
7348
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu name_entry_mode_menu
7349 1420 {
7350
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Keyboard", onKeyboardEntry },
7351
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Letter Grid", onLetterGridEntry },
7352
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Extended Letter Grid", onExtLetterGridEntry },
7353 };
7354
7355 static void set_controls_menu_active()
7356 {
7357
7358 }
7359
7360 enum
7361 {
7362 MENUID_WINDOW_LOCK_ASPECT,
7363 MENUID_WINDOW_LOCK_INTSCALE,
7364 MENUID_WINDOW_SAVE_SIZE,
7365 MENUID_WINDOW_SAVE_POS,
7366 MENUID_WINDOW_STRETCH,
7367 };
7368
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu window_menu
7369 2130 {
7370
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Lock Aspect Ratio", onDragAspect, MENUID_WINDOW_LOCK_ASPECT },
7371
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Lock Integer Scale", onIntegerScaling, MENUID_WINDOW_LOCK_INTSCALE },
7372
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Save Size Changes", onSaveDragResize, MENUID_WINDOW_SAVE_SIZE },
7373
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Save Position Changes", onWinPosSave, MENUID_WINDOW_SAVE_POS },
7374
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Stretch Game Area", onStretchGame, MENUID_WINDOW_STRETCH },
7375 };
7376 void call_zc_options_dlg();
7377 enum
7378 {
7379 MENUID_OPTIONS_PAUSE_BG,
7380 MENUID_OPTIONS_EPILEPSYPROT,
7381 };
7382
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu options_menu
7383 2485 {
7384
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Name &Entry Mode", &name_entry_mode_menu },
7385
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "S&napshot Format", &snapshot_format_menu },
7386
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Window Settings", &window_menu },
7387
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Epilepsy Flash Reduction", onEpilepsy, MENUID_OPTIONS_EPILEPSYPROT },
7388
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Pause In Background", onPauseInBackground, MENUID_OPTIONS_PAUSE_BG },
7389
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "More Options", call_zc_options_dlg },
7390 };
7391 enum
7392 {
7393 MENUID_SETTINGS_CONTROLS,
7394 MENUID_SETTINGS_CAPFPS,
7395 MENUID_SETTINGS_SHOWFPS,
7396 MENUID_SETTINGS_SHOWTIME,
7397 MENUID_SETTINGS_CLICK_FREEZE,
7398 MENUID_SETTINGS_TRANSLAYERS,
7399 MENUID_SETTINGS_NESQUIT,
7400 MENUID_SETTINGS_VOLKEYS,
7401 MENUID_SETTINGS_HEARTBEEP,
7402 MENUID_SETTINGS_SAVEINDICATOR,
7403 MENUID_SETTINGS_DEBUG,
7404 };
7405
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu settings_menu
7406 6035 {
7407
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Sound...", onSound },
7408
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "C&ontrols", &controls_menu, MENUID_SETTINGS_CONTROLS },
7409
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7410
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Options", &options_menu },
7411
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7412
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "&Cap FPS","F1", onThrottleFPS, MENUID_SETTINGS_CAPFPS },
7413
3/6
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
355 { "Show &FPS","F2", onShowFPS, MENUID_SETTINGS_SHOWFPS },
7414
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Show &Time", onShowTime, MENUID_SETTINGS_SHOWTIME },
7415
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Click to Freeze", onClickToFreeze, MENUID_SETTINGS_CLICK_FREEZE },
7416
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Cont. &Heart Beep", onHeartBeep, MENUID_SETTINGS_HEARTBEEP },
7417
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Show Trans. &Layers", onTransLayers, MENUID_SETTINGS_TRANSLAYERS },
7418
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Up+A+B To &Quit", onNESquit, MENUID_SETTINGS_NESQUIT },
7419
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Volume &Keys", onVolKeys, MENUID_SETTINGS_VOLKEYS },
7420
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Sa&ve Indicator", onSaveIndicator, MENUID_SETTINGS_SAVEINDICATOR },
7421
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7422
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Debu&g", onDebug, MENUID_SETTINGS_DEBUG },
7423 };
7424
7425 enum
7426 {
7427 MENUID_MISC_FULLSCREEN,
7428 MENUID_MISC_VIDMODE,
7429 MENUID_MISC_QUEST_INFO,
7430 MENUID_MISC_QUEST_DIR,
7431 MENUID_MISC_CONSOLE,
7432 MENUID_MISC_CLEAR_CONSOLE_ON_LOAD,
7433 };
7434
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu misc_menu
7435 5325 {
7436
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&About...", onAbout },
7437 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7438 // { "&Credits...", onCredits },
7439
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Fullscreen", onFullscreenMenu, MENUID_MISC_FULLSCREEN },
7440
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Video Mode...", onVidMode, MENUID_MISC_VIDMODE },
7441
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7442
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Quest Info...", onQuest, MENUID_MISC_QUEST_INFO },
7443
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Quest &MIDI Info...", onMIDICredits },
7444
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Quest &Directory...", onQstPath, MENUID_MISC_QUEST_DIR },
7445
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7446
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Take &Snapshot F12", onSnapshot },
7447
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Sc&reen Saver...", onScreenSaver },
7448
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Save ZC Configuration", OnSaveZCConfig },
7449
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Show Console", onConsole, MENUID_MISC_CONSOLE },
7450
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Clear Console on Qst Load", onClrConsoleOnLoad, MENUID_MISC_CLEAR_CONSOLE_ON_LOAD },
7451
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Clear Directory Cache", OnnClearQuestDir },
7452 };
7453
7454 enum
7455 {
7456 MENUID_REFILL_ARROWS,
7457 };
7458
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu refill_menu
7459 2130 {
7460
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Life", onRefillLife },
7461
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Magic", onRefillMagic },
7462
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Bombs", onCheatBombs },
7463
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Rupees", onCheatRupies },
7464
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Arrows", onCheatArrows, MENUID_REFILL_ARROWS },
7465 };
7466
7467 enum
7468 {
7469 MENUID_SHOW_L0,
7470 MENUID_SHOW_L1,
7471 MENUID_SHOW_L2,
7472 MENUID_SHOW_L3,
7473 MENUID_SHOW_L4,
7474 MENUID_SHOW_L5,
7475 MENUID_SHOW_L6,
7476 MENUID_SHOW_OVER,
7477 MENUID_SHOW_PUSH,
7478 MENUID_SHOW_FFC,
7479 MENUID_SHOW_SPR,
7480 MENUID_SHOW_SCRIPTNAME,
7481 MENUID_SHOW_SOLIDITY,
7482 MENUID_SHOW_HITBOX,
7483 MENUID_SHOW_EFFECT,
7484 };
7485
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu show_menu
7486 6745 {
7487
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Combos", onShowLayer0, MENUID_SHOW_L0 },
7488
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 1", onShowLayer1, MENUID_SHOW_L1 },
7489
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 2", onShowLayer2, MENUID_SHOW_L2 },
7490
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 3", onShowLayer3, MENUID_SHOW_L3 },
7491
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 4", onShowLayer4, MENUID_SHOW_L4 },
7492
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 5", onShowLayer5, MENUID_SHOW_L5 },
7493
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Layer 6", onShowLayer6, MENUID_SHOW_L6 },
7494
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Overhead Combos", onShowLayerO, MENUID_SHOW_OVER },
7495
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Push Blocks", onShowLayerP, MENUID_SHOW_PUSH },
7496
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Freeform Combos", onShowLayerF, MENUID_SHOW_FFC },
7497
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Sprites", onShowLayerS, MENUID_SHOW_SPR },
7498
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7499
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Current FFC Scripts", onShowFFScripts, MENUID_SHOW_SCRIPTNAME },
7500
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 {},
7501
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Walkability", onShowLayerW, MENUID_SHOW_SOLIDITY },
7502
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Hitboxes", onShowHitboxes, MENUID_SHOW_HITBOX },
7503
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Effects", onShowLayerE, MENUID_SHOW_EFFECT },
7504
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Info Opacity", onShowInfoOpacity },
7505 };
7506
7507 enum
7508 {
7509 MENUID_CHEAT_CHOP_L1,
7510 MENUID_CHEAT_CHOP_L2,
7511 MENUID_CHEAT_CHOP_L3,
7512 MENUID_CHEAT_CHOP_L4,
7513 MENUID_CHEAT_INVULN,
7514 MENUID_CHEAT_NOCLIP,
7515 MENUID_CHEAT_IGNORESV,
7516 MENUID_CHEAT_GOFAST,
7517 };
7518
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 static NewMenu cheat_menu
7519 6035 {
7520
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Set &Cheat", onCheat },
7521
1/2
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
355 { MENUID_CHEAT_CHOP_L1 },
7522
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Re&fill", &refill_menu },
7523
1/2
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
355 { MENUID_CHEAT_CHOP_L2 },
7524
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Invincible", onClock, MENUID_CHEAT_INVULN },
7525
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Ma&x Bombs...", onMaxBombs },
7526
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Heart Containers...", onHeartC },
7527
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Magic Containers...", onMagicC },
7528
1/2
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
355 { MENUID_CHEAT_CHOP_L3 },
7529
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Player Data...", onCheatConsole },
7530
1/2
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
355 { MENUID_CHEAT_CHOP_L4 },
7531
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Walk Through &Walls", onNoWalls, MENUID_CHEAT_NOCLIP },
7532
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Player Ignores Side&view", onIgnoreSideview, MENUID_CHEAT_IGNORESV },
7533
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Quick Movement", onGoFast, MENUID_CHEAT_GOFAST },
7534
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Kill All Enemies", onKillCheat },
7535
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Trigger &Secrets", onSecretsCheat },
7536
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Trigger Secrets Perm", onSecretsCheatPerm },
7537
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Show/Hide Layer", &show_menu },
7538
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "Toggle &Light", onLightSwitch },
7539
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Goto Location...", onGoTo },
7540 };
7541
7542 #if DEVLEVEL > 0
7543 int32_t devLogging();
7544 int32_t devDebug();
7545 int32_t devTimestmp();
7546 #if DEVLEVEL > 1
7547 int32_t setCheat();
7548 #endif //DEVLEVEL > 1
7549 enum
7550 {
7551 MENUID_DEV_LOGGING,
7552 MENUID_DEV_DEBUG,
7553 MENUID_DEV_TIMESTAMP,
7554 MENUID_DEV_SETCHEAT,
7555 };
7556 static NewMenu dev_menu
7557 {
7558 { "&Force Error Log", devLogging, MENUID_DEV_LOGGING },
7559 // { "&Extra Debug Log", devDebug, MENUID_DEV_DEBUG },
7560 { "&Timestamp Log", devTimestmp, MENUID_DEV_TIMESTAMP },
7561 #if DEVLEVEL > 1
7562 {},
7563 { "Set &Cheat", setCheat, MENUID_DEV_SETCHEAT },
7564 #endif //DEVLEVEL > 1
7565 };
7566 int32_t devLogging()
7567 {
7568 dev_logging = !dev_logging;
7569 dev_menu.select_uid(MENUID_DEV_LOGGING, dev_logging);
7570 return D_O_K;
7571 }
7572 // int32_t devDebug()
7573 // {
7574 // dev_debug = !dev_debug;
7575 // dev_menu.select_uid(MENUID_DEV_DEBUG, dev_debug);
7576 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7577 // return D_O_K;
7578 // }
7579 int32_t devTimestmp()
7580 {
7581 dev_timestmp = !dev_timestmp;
7582 dev_menu.select_uid(MENUID_DEV_TIMESTAMP, dev_timestmp);
7583 return D_O_K;
7584 }
7585 #if DEVLEVEL > 1
7586 int32_t setCheat()
7587 {
7588 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7589 return D_O_K;
7590 }
7591 #endif //DEVLEVEL > 1
7592 #endif //DEVLEVEL > 0
7593
7594 enum
7595 {
7596 MENUID_PLAYER_CHEAT,
7597 };
7598
1/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
355 TopMenu the_player_menu
7599 2130 {
7600
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Game", &game_menu },
7601
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Settings", &settings_menu },
7602
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Cheat", &cheat_menu, MENUID_PLAYER_CHEAT, true },
7603
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&Replay", &replay_menu },
7604
2/4
✓ Branch 0 taken 355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
355 { "&ZC", &misc_menu },
7605 #if DEVLEVEL > 0
7606 { "&Dev", &dev_menu },
7607 #endif
7608 };
7609
7610 int32_t onPauseInBackground()
7611 {
7612 if(jwin_alert3(
7613 "Toggle Pause In Background",
7614 "This action will change whether ZC Player pauses when the window loses focus.",
7615 "",
7616 "Proceed?",
7617 "&Yes",
7618 "&No",
7619 NULL,
7620 'y',
7621 'n',
7622 0,
7623 get_zc_font(font_lfont)) == 1)
7624 {
7625 pause_in_background = pause_in_background ? 0 : 1;
7626 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7627 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7628 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7629 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7630 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7631 }
7632 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7633 return D_O_K;
7634 }
7635
7636 int32_t onKeyboardEntry()
7637 {
7638 NameEntryMode=0;
7639 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7640 return D_O_K;
7641 }
7642
7643 int32_t onLetterGridEntry()
7644 {
7645 NameEntryMode=1;
7646 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7647 return D_O_K;
7648 }
7649
7650 int32_t onExtLetterGridEntry()
7651 {
7652 NameEntryMode=2;
7653 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7654 return D_O_K;
7655 }
7656
7657 static BITMAP* oldscreen;
7658 int32_t onFullscreenMenu()
7659 {
7660 PALETTE oldpal;
7661 get_palette(oldpal);
7662
7663 fullscreen = !fullscreen;
7664 all_toggle_fullscreen(fullscreen);
7665 zc_set_config("zeldadx","fullscreen",fullscreen);
7666
7667 zc_set_palette(oldpal);
7668 gui_mouse_focus=0;
7669 extern int32_t switch_type;
7670 switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7671 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7672 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7673 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7674 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7675 misc_menu.select_uid(MENUID_MISC_VIDMODE, isFullScreen());
7676
7677 return D_O_K;
7678 }
7679
7680 266 void fix_menu()
7681 {
7682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266 times.
266 if(!debug_enabled)
7683 266 settings_menu.chop_index = 13;
7684 266 }
7685
7686 int32_t onSetSnapshotFormat(SnapshotType format)
7687 {
7688 SnapshotFormat = format;
7689 zc_set_config("zeldadx", "snapshot_format", format);
7690 snapshot_format_menu.select_only_index(format);
7691 return D_O_K;
7692 }
7693
7694
7695 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7696 {
7697 PALETTE tmp;
7698
7699 for(int32_t i=0; i<256; i++)
7700 {
7701 tmp[i].r=r;
7702 tmp[i].g=g;
7703 tmp[i].b=b;
7704 }
7705
7706 fade_interpolate(src,tmp,dest,pos,from,to);
7707 }
7708
7709 88 void system_pal(bool force)
7710 {
7711
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
88 if(is_sys_pal && !force) return;
7712 88 is_sys_pal = true;
7713 88 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7714 88 hw_palette = &syspal;
7715 88 update_hw_pal = true;
7716 88 }
7717
7718 static uint32_t entered_sys_pal = 0;
7719 88 void enter_sys_pal()
7720 {
7721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(is_sys_pal)
7722 {
7723 if(entered_sys_pal)
7724 ++entered_sys_pal;
7725 return;
7726 }
7727 88 sys_mouse();
7728 88 system_pal(true);
7729 88 ++entered_sys_pal;
7730 88 }
7731 88 void exit_sys_pal()
7732 {
7733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(entered_sys_pal)
7734 {
7735
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!--entered_sys_pal)
7736 {
7737 88 game_pal();
7738 88 game_mouse();
7739 88 }
7740 88 }
7741 88 }
7742
7743 void switch_out_callback()
7744 {
7745 if (pause_in_background && !MenuOpen)
7746 {
7747 System();
7748 }
7749 }
7750
7751 void switch_in_callback()
7752 {
7753 }
7754
7755 1141 void game_pal()
7756 {
7757 1141 is_sys_pal = false;
7758 1141 entered_sys_pal = 0;
7759 1141 hw_palette = &RAMpal;
7760 1141 update_hw_pal = true;
7761 1141 }
7762
7763 static char bar_str[] = "";
7764
7765 61 void music_pause()
7766 {
7767 //al_pause_duh(tmplayer);
7768 61 zcmusic_pause(zcmusic, ZCM_PAUSE);
7769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(zcmixer->oldtrack)
7770 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7771 61 zc_midi_pause();
7772 61 }
7773
7774 void music_resume()
7775 {
7776 //al_resume_duh(tmplayer);
7777 zcmusic_pause(zcmusic, ZCM_RESUME);
7778 if (zcmixer->oldtrack)
7779 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7780 zc_midi_resume();
7781 }
7782
7783 7615 void music_stop()
7784 {
7785 //al_stop_duh(tmplayer);
7786 //unload_duh(tmusic);
7787 //tmusic=NULL;
7788 //tmplayer=NULL;
7789 7615 zcmusic_stop(zcmusic);
7790 7615 zcmusic_unload_file(zcmusic);
7791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7615 times.
7615 if (zcmixer->oldtrack)
7792 {
7793 zcmusic_stop(zcmixer->oldtrack);
7794 zcmusic_unload_file(zcmixer->oldtrack);
7795 }
7796 7615 zcmixer->newtrack = NULL;
7797 7615 zc_stop_midi();
7798 7615 currmidi=-1;
7799 7615 }
7800
7801 bool reload_fonts = false;
7802 void System()
7803 {
7804 mouse_down = gui_mouse_b();
7805 music_pause();
7806 pause_all_sfx();
7807 MenuOpen = true;
7808 enter_sys_pal();
7809 // FONT *oldfont=font;
7810 // font=tfont;
7811
7812 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7813 misc_menu.disable_uid(MENUID_MISC_VIDMODE, isFullScreen());
7814
7815 #if DEVLEVEL > 1
7816 dev_menu.disable_uid(MENUID_DEV_SETCHEAT, !Playing);
7817 #endif
7818 game_menu.disable_uid(MENUID_GAME_LOADQUEST, getsaveslot() < 0);
7819 game_menu.disable_uid(MENUID_GAME_ENDGAME, !Playing);
7820 misc_menu.disable_uid(MENUID_MISC_QUEST_INFO, !Playing);
7821 misc_menu.disable_uid(MENUID_MISC_QUEST_DIR, Playing);
7822 clear_keybuf();
7823
7824 clear_bitmap(menu_bmp);
7825 oldscreen = screen;
7826 screen = menu_bmp;
7827
7828 the_player_menu.reset_state();
7829 the_player_menu.position(0, 0);
7830
7831 bool running = true;
7832 bool esc = key[KEY_ESC] || cMbtn();
7833 bool autopop = esc;
7834 do
7835 {
7836 if(reload_fonts)
7837 {
7838 init_custom_fonts();
7839 clear_bitmap(menu_bmp);
7840 broadcast_dialog_message(MSG_DRAW, 0);
7841 reload_fonts = false;
7842 }
7843 if(handle_close_btn_quit())
7844 break;
7845
7846 //update submenus
7847 {
7848 settings_menu.disable_uid(MENUID_SETTINGS_CONTROLS, replay_is_replaying());
7849 settings_menu.select_uid(MENUID_SETTINGS_CAPFPS, Throttlefps);
7850 settings_menu.select_uid(MENUID_SETTINGS_SHOWFPS, ShowFPS);
7851 settings_menu.select_uid(MENUID_SETTINGS_SHOWTIME, ShowGameTime);
7852 settings_menu.select_uid(MENUID_SETTINGS_CLICK_FREEZE, ClickToFreeze);
7853 settings_menu.select_uid(MENUID_SETTINGS_TRANSLAYERS, TransLayers);
7854 settings_menu.select_uid(MENUID_SETTINGS_NESQUIT, NESquit);
7855 settings_menu.select_uid(MENUID_SETTINGS_VOLKEYS, volkeys);
7856
7857 window_menu.select_uid(MENUID_WINDOW_LOCK_ASPECT, DragAspect);
7858 window_menu.select_uid(MENUID_WINDOW_LOCK_INTSCALE, scaleForceInteger);
7859 window_menu.select_uid(MENUID_WINDOW_SAVE_SIZE, SaveDragResize);
7860 window_menu.select_uid(MENUID_WINDOW_SAVE_POS, SaveWinPos);
7861 window_menu.select_uid(MENUID_WINDOW_STRETCH, stretchGame);
7862
7863 options_menu.select_uid(MENUID_OPTIONS_EPILEPSYPROT, epilepsyFlashReduction);
7864 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7865
7866 name_entry_mode_menu.select_only_index(NameEntryMode);
7867
7868 misc_menu.select_uid(MENUID_MISC_CONSOLE, console_enabled);
7869 misc_menu.select_uid(MENUID_MISC_CLEAR_CONSOLE_ON_LOAD, clearConsoleOnLoad);
7870
7871 bool nocheat = (replay_is_replaying() || !Playing
7872 || (!maxcheat && !zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7873 the_player_menu.disable_uid(MENUID_PLAYER_CHEAT, nocheat);
7874 refill_menu.disable_uid(MENUID_REFILL_ARROWS, !get_qr(qr_TRUEARROWS));
7875 cheat_menu.chop_index.reset();
7876 if(cheat < 4)
7877 cheat_menu.chop_index = cheat_menu.ind_at(MENUID_CHEAT_CHOP_L1+cheat);
7878 cheat_menu.select_uid(MENUID_CHEAT_INVULN, getClock());
7879 cheat_menu.select_uid(MENUID_CHEAT_NOCLIP, toogam);
7880 cheat_menu.select_uid(MENUID_CHEAT_IGNORESV, ignoreSideview);
7881 cheat_menu.select_uid(MENUID_CHEAT_GOFAST, gofast);
7882
7883 show_menu.select_uid(MENUID_SHOW_L0, show_layer_0);
7884 show_menu.select_uid(MENUID_SHOW_L1, show_layer_1);
7885 show_menu.select_uid(MENUID_SHOW_L2, show_layer_2);
7886 show_menu.select_uid(MENUID_SHOW_L3, show_layer_3);
7887 show_menu.select_uid(MENUID_SHOW_L4, show_layer_4);
7888 show_menu.select_uid(MENUID_SHOW_L5, show_layer_5);
7889 show_menu.select_uid(MENUID_SHOW_L6, show_layer_6);
7890 show_menu.select_uid(MENUID_SHOW_OVER, show_layer_over);
7891 show_menu.select_uid(MENUID_SHOW_PUSH, show_layer_push);
7892 show_menu.select_uid(MENUID_SHOW_SPR, show_sprites);
7893 show_menu.select_uid(MENUID_SHOW_FFC, show_ffcs);
7894 show_menu.select_uid(MENUID_SHOW_SOLIDITY, show_walkflags);
7895 show_menu.select_uid(MENUID_SHOW_SCRIPTNAME, show_ff_scripts);
7896 show_menu.select_uid(MENUID_SHOW_HITBOX, show_hitboxes);
7897 show_menu.select_uid(MENUID_SHOW_EFFECT, show_effectflags);
7898
7899 settings_menu.select_uid(MENUID_SETTINGS_HEARTBEEP, heart_beep);
7900 settings_menu.select_uid(MENUID_SETTINGS_SAVEINDICATOR, use_save_indicator);
7901
7902 replay_menu.by_uid(MENUID_REPLAY_STOP)->text = fmt::format("Stop {}",
7903 replay_get_mode() == ReplayMode::Record ? "recording" : "replaying");
7904
7905 replay_menu.select_uid(MENUID_REPLAY_RECORDNEW, zc_get_config("zeldadx", "replay_new_saves", false));
7906 replay_menu.disable_uid(MENUID_REPLAY_STOP, !replay_is_active());
7907 replay_menu.disable_uid(MENUID_REPLAY_SAVE, replay_get_mode() != ReplayMode::Record);
7908 replay_menu.select_uid(MENUID_REPLAY_SNAP_ALL, replay_is_snapshot_all_frames());
7909
7910 snapshot_format_menu.select_only_index(SnapshotFormat);
7911 }
7912
7913 if(debug_enabled)
7914 settings_menu.select_uid(MENUID_SETTINGS_DEBUG, get_debug());
7915
7916 if(autopop)
7917 clear_keybuf();
7918 the_player_menu.run(true);
7919 if(autopop)
7920 {
7921 the_player_menu.pop_sub(0, &the_player_menu);
7922 the_player_menu.draw(screen, the_player_menu.hovered_ind());
7923 autopop = false;
7924 update_hw_screen();
7925 }
7926
7927 update_hw_screen();
7928
7929 auto mb = gui_mouse_b();
7930 if(XOR(mb, mouse_down))
7931 {
7932 if(!the_player_menu.has_mouse())
7933 if(mb)
7934 break;
7935 mouse_down = mb;
7936 }
7937
7938 if(input_idle(true) > after_time())
7939 // run Screeen Saver
7940 {
7941 // Screen saver enabled for now.
7942 clear_keybuf();
7943 Matrix(ss_speed, ss_density, 0);
7944 system_pal(true);
7945 sys_mouse();
7946 }
7947
7948 poll_keyboard();
7949 if(esc)
7950 {
7951 if(!key[KEY_ESC])
7952 esc = false;
7953 }
7954
7955 if(keypressed() && !CHECK_ALT) //System hotkeys
7956 {
7957 auto c = peekkey();
7958 bool eatkey = true;
7959 switch(c>>8)
7960 {
7961 //Spare keys used by the menu
7962 case KEY_UP:
7963 case KEY_DOWN:
7964 case KEY_LEFT:
7965 case KEY_RIGHT:
7966 eatkey = false;
7967 break;
7968 case KEY_F1:
7969 onThrottleFPS();
7970 break;
7971 case KEY_F2:
7972 onShowFPS();
7973 break;
7974 case KEY_F6:
7975 onTryQuitMenu();
7976 break;
7977 #ifndef ALLEGRO_MACOSX
7978 case KEY_F9:
7979 onReset();
7980 break;
7981 case KEY_F10:
7982 onExit();
7983 break;
7984 #else
7985 case KEY_F7:
7986 onReset();
7987 break;
7988 case KEY_F8:
7989 onExit();
7990 break;
7991 #endif
7992 case KEY_F12:
7993 onSnapshot();
7994 break;
7995 case KEY_TAB:
7996 onDebug();
7997 break;
7998 case KEY_ESC:
7999 if(!esc)
8000 running = false;
8001 break;
8002 }
8003 if(eatkey)
8004 readkey();
8005 }
8006 if(Quit || (GameFlags & GAMEFLAG_TRYQUIT))
8007 break;
8008 }
8009 while(running);
8010
8011 screen = oldscreen;
8012
8013 mouse_down=gui_mouse_b();
8014 MenuOpen = false;
8015 if(Quit)
8016 {
8017 kill_sfx();
8018 music_stop();
8019 update_hw_screen();
8020 }
8021 else
8022 {
8023 music_resume();
8024 resume_all_sfx();
8025
8026 if(rc)
8027 ringcolor(false);
8028 }
8029 exit_sys_pal();
8030
8031 eat_buttons();
8032
8033 rc=false;
8034 clear_keybuf();
8035
8036 zc_init_apply_cheat_delta();
8037 }
8038
8039 266 void fix_dialogs()
8040 {
8041 266 jwin_center_dialog(about_dlg);
8042 266 jwin_center_dialog(gamepad_dlg);
8043 266 jwin_center_dialog(credits_dlg);
8044 266 jwin_center_dialog(gamemode_dlg);
8045 266 jwin_center_dialog(getnum_dlg);
8046 266 jwin_center_dialog(goto_dlg);
8047 266 jwin_center_dialog(keyboard_control_dlg);
8048 266 jwin_center_dialog(midi_dlg);
8049 266 jwin_center_dialog(quest_dlg);
8050 266 jwin_center_dialog(scrsaver_dlg);
8051 266 jwin_center_dialog(sound_dlg);
8052 266 jwin_center_dialog(triforce_dlg);
8053 266 }
8054
8055 /*****************************/
8056 /**** Custom Sound System ****/
8057 /*****************************/
8058
8059 4332 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8060 {
8061
3/4
✓ Branch 0 taken 4332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4284 times.
✓ Branch 3 taken 48 times.
4332 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8062 }
8063
8064 290 int32_t get_emusic_volume()
8065 {
8066 290 int32_t temp_volume = emusic_volume;
8067
2/4
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✗ Branch 3 not taken.
290 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8068 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if (!zcmusic)
8070 290 return temp_volume;
8071 return (temp_volume * zcmusic->fadevolume) / 10000;
8072 290 }
8073
8074 int32_t get_zcmusicpos()
8075 {
8076 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8077 return debugtracething;
8078 return 0;
8079 }
8080
8081 void set_zcmusicpos(int32_t position)
8082 {
8083 zcmusic_set_curpos(zcmusic, position);
8084 }
8085
8086 void set_zcmusicspeed(int32_t speed)
8087 {
8088 zcmusic_set_speed(zcmusic, speed);
8089 }
8090
8091 int32_t get_zcmusiclen()
8092 {
8093 return zcmusic_get_length(zcmusic);
8094 }
8095
8096 3 void set_zcmusicloop(double start, double end)
8097 {
8098 3 zcmusic_set_loop(zcmusic, start, end);
8099 3 }
8100
8101 64182 void jukebox(int32_t index,int32_t loop)
8102 {
8103
2/2
✓ Branch 0 taken 64156 times.
✓ Branch 1 taken 26 times.
64182 if (is_headless())
8104 64156 return;
8105
8106 26 music_stop();
8107
8108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(index<0) index=MAXMIDIS-1;
8109
8110
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(index>=MAXMIDIS) index=0;
8111
8112 26 music_stop();
8113
8114 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8115 // stuck notes when a song stops. This fixes it.
8116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(strcmp(midi_driver->name, "DIGMID")==0)
8117 zc_set_volume(0, 0);
8118
8119 26 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8120 26 zc_play_midi((MIDI*)tunes[index].data,loop);
8121
8122
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(tunes[index].start>0)
8123 zc_midi_seek(tunes[index].start);
8124
8125 26 midi_loop_start = tunes[index].loop_start;
8126 26 midi_loop_end = tunes[index].loop_end;
8127
8128 26 currmidi=index;
8129 26 master_volume(digi_volume, midi_volume);
8130 //midi_paused=false;
8131 64182 }
8132
8133 64193 void jukebox(int32_t index)
8134 {
8135
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index<0) index=MAXMIDIS-1;
8136
8137
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index>=MAXMIDIS) index=0;
8138
8139 // do nothing if it's already playing
8140
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 64182 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
64193 if(index==currmidi && midi_pos>=0)
8141 {
8142 11 return;
8143 }
8144
8145 64182 jukebox(index,tunes[index].loop);
8146 64193 }
8147
8148 160 void play_DmapMusic()
8149 {
8150
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 60 times.
160 if (is_headless())
8151 100 return;
8152
8153 static char tfile[2048];
8154 static int32_t ttrack=0;
8155 60 bool domidi=false;
8156
8157 60 int32_t fadeoutframes = 0;
8158
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (zcmusic != NULL)
8159 fadeoutframes = zcmusic->fadeoutframes;
8160
8161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(DMaps[currdmap].tmusic[0]!=0)
8162 {
8163 if(zcmusic==NULL ||
8164 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8165 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8166 {
8167 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8168 {
8169 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8170 {
8171 if (zcmusic != NULL)
8172 {
8173 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8174 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8175 }
8176 }
8177 }
8178 else
8179 {
8180 if (zcmusic != NULL)
8181 {
8182 zcmusic_stop(zcmusic);
8183 zcmusic_unload_file(zcmusic);
8184 zcmusic = NULL;
8185 zcmixer->newtrack = NULL;
8186 }
8187
8188 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8189 zcmixer->newtrack = zcmusic;
8190
8191 if (zcmusic != NULL)
8192 {
8193 zc_stop_midi();
8194 strcpy(tfile, DMaps[currdmap].tmusic);
8195 zcmusic_play(zcmusic, emusic_volume);
8196 int32_t temptracks = 0;
8197 temptracks = zcmusic_get_tracks(zcmusic);
8198 temptracks = (temptracks < 2) ? 1 : temptracks;
8199 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8200 zcmusic_change_track(zcmusic, ttrack);
8201 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8202 }
8203 else
8204 {
8205 tfile[0] = 0;
8206 domidi = true;
8207 }
8208 }
8209 }
8210 }
8211 else
8212 {
8213
3/8
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8214 {
8215 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8216 }
8217 else
8218 {
8219 60 domidi = true;
8220 }
8221 }
8222
8223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(domidi)
8224 {
8225 60 int32_t m=DMaps[currdmap].midi;
8226
8227
2/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 switch(m)
8228 {
8229 case 1:
8230 37 jukebox(ZC_MIDI_OVERWORLD);
8231 37 break;
8232
8233 case 2:
8234 jukebox(ZC_MIDI_DUNGEON);
8235 break;
8236
8237 case 3:
8238 jukebox(ZC_MIDI_LEVEL9);
8239 break;
8240
8241 default:
8242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8243 jukebox(m+MIDIOFFSET_DMAP);
8244 else
8245 23 music_stop();
8246 23 }
8247 60 }
8248 160 }
8249
8250 34935 void playLevelMusic()
8251 {
8252
2/2
✓ Branch 0 taken 34875 times.
✓ Branch 1 taken 60 times.
34935 if (is_headless())
8253 34875 return;
8254
8255 60 int32_t m=tmpscr->screen_midi;
8256
8257
1/6
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
60 switch(m)
8258 {
8259 case -2:
8260 music_stop();
8261 break;
8262
8263 case -1:
8264 60 play_DmapMusic();
8265 60 break;
8266
8267 case 1:
8268 jukebox(ZC_MIDI_OVERWORLD);
8269 break;
8270
8271 case 2:
8272 jukebox(ZC_MIDI_DUNGEON);
8273 break;
8274
8275 case 3:
8276 jukebox(ZC_MIDI_LEVEL9);
8277 break;
8278
8279 default:
8280 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8281 jukebox(m+MIDIOFFSET_MAPSCR);
8282 else
8283 music_stop();
8284 }
8285 34935 }
8286
8287 4306 void master_volume(int32_t dv,int32_t mv)
8288 {
8289
7/8
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2299 times.
✓ Branch 2 taken 1967 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 2299 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1967 times.
✓ Branch 7 taken 332 times.
4306 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8290
8291
7/8
✓ Branch 0 taken 2004 times.
✓ Branch 1 taken 2302 times.
✓ Branch 2 taken 1998 times.
✓ Branch 3 taken 304 times.
✓ Branch 4 taken 2302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1998 times.
✓ Branch 7 taken 304 times.
4306 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8292
8293
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4280 times.
✓ Branch 2 taken 4306 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 4280 times.
4306 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8294 4306 int32_t temp_vol = midi_volume;
8295
2/2
✓ Branch 0 taken 4040 times.
✓ Branch 1 taken 266 times.
4306 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8296 266 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8297 4306 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8298 4306 }
8299
8300 /*****************/
8301 /***** SFX *****/
8302 /*****************/
8303
8304 // array of voices, one for each sfx sample in the data file
8305 // 0+ = voice #
8306 // -1 = voice not allocated
8307 266 void Z_init_sound()
8308 {
8309
2/2
✓ Branch 0 taken 68096 times.
✓ Branch 1 taken 266 times.
68362 for(int32_t i=0; i<WAV_COUNT; i++)
8310 68096 sfx_voice[i]=-1;
8311
8312 266 const char* midis[ZC_MIDI_COUNT] = {
8313 "assets/dungeon.mid",
8314 "assets/ending.mid",
8315 "assets/gameover.mid",
8316 "assets/level9.mid",
8317 "assets/overworld.mid",
8318 "assets/title.mid",
8319 "assets/triforce.mid",
8320 };
8321
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 266 times.
2128 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8322 {
8323 1862 tunes[i].data = load_midi(midis[i]);
8324
1/2
✓ Branch 0 taken 1862 times.
✗ Branch 1 not taken.
1862 if (!tunes[i].data)
8325 Z_error_fatal("Missing required file %s\n", midis[i]);
8326 1862 }
8327
8328
2/2
✓ Branch 0 taken 67032 times.
✓ Branch 1 taken 266 times.
67298 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8329 67032 tunes[ZC_MIDI_COUNT+j].data=NULL;
8330
8331 266 master_volume(digi_volume,midi_volume);
8332 266 }
8333
8334 // returns number of voices currently allocated
8335 int32_t sfx_count()
8336 {
8337 int32_t c=0;
8338
8339 for(int32_t i=0; i<WAV_COUNT; i++)
8340 if(sfx_voice[i]!=-1)
8341 ++c;
8342
8343 return c;
8344 }
8345
8346 // clean up finished samples
8347 18118893 void sfx_cleanup()
8348 {
8349
2/2
✓ Branch 0 taken 4638436608 times.
✓ Branch 1 taken 18118893 times.
4656555501 for(int32_t i=0; i<WAV_COUNT; i++)
8350
3/4
✓ Branch 0 taken 1257462 times.
✓ Branch 1 taken 4637179146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257462 times.
4639694070 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8351 {
8352 1257462 deallocate_voice(sfx_voice[i]);
8353 1257462 sfx_voice[i]=-1;
8354 1257462 }
8355 18118893 }
8356
8357 1257599 SAMPLE* sfx_get_sample(int32_t index)
8358 {
8359 // check index
8360
2/4
✓ Branch 0 taken 1257599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257599 times.
1257599 if (index<=0 || index>=WAV_COUNT)
8361 return nullptr;
8362
8363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257599 times.
1257599 if (sfxdat)
8364 {
8365 if (index<Z35)
8366 {
8367 return (SAMPLE*)sfxdata[index].dat;
8368 }
8369 else
8370 {
8371 return (SAMPLE*)sfxdata[Z35].dat;
8372 }
8373 }
8374 else
8375 {
8376 1257599 return &customsfxdata[index];
8377 }
8378
8379 return nullptr;
8380 1257599 }
8381
8382 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8383 // if a voice is already allocated (and/or playing), then it just returns true
8384 // Returns true: voice is allocated
8385 // false: unsuccessful
8386 1848181 bool sfx_init(int32_t index)
8387 {
8388 // check index
8389
3/4
✓ Branch 0 taken 1388315 times.
✓ Branch 1 taken 459866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1388315 times.
1848181 if(index<=0 || index>=WAV_COUNT)
8390 459866 return false;
8391
8392
2/2
✓ Branch 0 taken 130762 times.
✓ Branch 1 taken 1257553 times.
1388315 if (sfx_voice[index] == -1)
8393 {
8394 1257553 SAMPLE* sample = sfx_get_sample(index);
8395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257553 times.
1257553 if (!sample)
8396 return false;
8397
8398 1257553 sfx_voice[index] = allocate_voice(sample);
8399 1257553 }
8400
8401 1388315 return sfx_voice[index] != -1;
8402 1848181 }
8403
8404 793 int32_t sfx_get_default_freq(int32_t index)
8405 {
8406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (sfxdat)
8407 {
8408 if (index < Z35)
8409 {
8410 return ((SAMPLE*)sfxdata[index].dat)->freq;
8411 }
8412 else
8413 {
8414 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8415 }
8416 }
8417 else
8418 {
8419 793 return customsfxdata[index].freq;
8420 }
8421 793 }
8422
8423 int32_t sfx_get_length(int32_t index)
8424 {
8425 if (sfxdat)
8426 {
8427 if (index < Z35)
8428 {
8429 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8430 }
8431 else
8432 {
8433 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8434 }
8435 }
8436 else
8437 {
8438 return int32_t(customsfxdata[index].len);
8439 }
8440 }
8441
8442 // plays an sfx sample
8443 1848048 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8444 {
8445
2/2
✓ Branch 0 taken 1388245 times.
✓ Branch 1 taken 459803 times.
1848048 if(!sfx_init(index))
8446 459803 return;
8447
2/2
✓ Branch 0 taken 1387452 times.
✓ Branch 1 taken 793 times.
1388245 if (!is_headless())
8448 {
8449 793 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8450 793 voice_set_pan(sfx_voice[index], pan);
8451
8452 // Only used by ZScript currently
8453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (freq <= -1)
8454 {
8455 793 freq = sfx_get_default_freq(index);
8456 793 }
8457 793 voice_set_frequency(sfx_voice[index], freq);
8458
8459 // Only used by ZScript currently
8460 793 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8461
2/4
✓ Branch 0 taken 793 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793 times.
✗ Branch 3 not taken.
793 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8462 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8463 793 voice_set_volume(sfx_voice[index], temp_volume);
8464
8465 793 int32_t pos = voice_get_position(sfx_voice[index]);
8466
8467
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 278 times.
793 if (restart) voice_set_position(sfx_voice[index], 0);
8468
8469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (pos <= 0)
8470 793 voice_start(sfx_voice[index]);
8471 793 }
8472
8473
4/4
✓ Branch 0 taken 856526 times.
✓ Branch 1 taken 531719 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 856511 times.
1388245 if (restart && replay_is_debug())
8474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 856511 times.
856511 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8475 1848048 }
8476
8477 // true if sfx is allocated
8478 199397 bool sfx_allocated(int32_t index)
8479 {
8480
3/4
✓ Branch 0 taken 33965 times.
✓ Branch 1 taken 165432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33965 times.
199397 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8481 }
8482
8483 // start it (in loop mode) if it's not already playing,
8484 // otherwise adjust it to play in loop mode -DD
8485 117057 void cont_sfx(int32_t index)
8486 {
8487
2/2
✓ Branch 0 taken 116924 times.
✓ Branch 1 taken 133 times.
117057 if (is_headless())
8488 116924 return;
8489
8490
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 63 times.
133 if(!sfx_init(index))
8491 {
8492 63 return;
8493 }
8494
8495
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(voice_get_position(sfx_voice[index])<=0)
8496 {
8497 70 voice_set_position(sfx_voice[index],0);
8498 70 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8499 70 voice_set_volume(sfx_voice[index], sfx_volume);
8500 70 voice_start(sfx_voice[index]);
8501 70 }
8502 else
8503 {
8504 adjust_sfx(index, 128, true);
8505 }
8506 117057 }
8507
8508 // adjust parameters while playing
8509 6765 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8510 {
8511
4/6
✓ Branch 0 taken 4481 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 4481 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4481 times.
6765 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8512 6765 return;
8513
8514 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8515 voice_set_pan(sfx_voice[index],pan);
8516 6765 }
8517
8518 // pauses a voice
8519 3223 void pause_sfx(int32_t index)
8520 {
8521
3/6
✓ Branch 0 taken 3223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3223 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3223 times.
3223 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8522 voice_stop(sfx_voice[index]);
8523 3223 }
8524
8525 // resumes a voice
8526 1360 void resume_sfx(int32_t index)
8527 {
8528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (is_headless())
8529 1360 return;
8530
8531 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8532 voice_start(sfx_voice[index]);
8533 1360 }
8534
8535 // pauses all active voices
8536 1078 void pause_all_sfx()
8537 {
8538
2/2
✓ Branch 0 taken 275968 times.
✓ Branch 1 taken 1078 times.
277046 for(int32_t i=0; i<WAV_COUNT; i++)
8539
2/2
✓ Branch 0 taken 275966 times.
✓ Branch 1 taken 2 times.
275970 if(sfx_voice[i]!=-1)
8540 2 voice_stop(sfx_voice[i]);
8541 1078 }
8542
8543 // resumes all paused voices
8544 1017 void resume_all_sfx()
8545 {
8546
2/2
✓ Branch 0 taken 260352 times.
✓ Branch 1 taken 1017 times.
261369 for(int32_t i=0; i<WAV_COUNT; i++)
8547
1/2
✓ Branch 0 taken 260352 times.
✗ Branch 1 not taken.
260352 if(sfx_voice[i]!=-1)
8548 voice_start(sfx_voice[i]);
8549 1017 }
8550
8551 // stops an sfx and deallocates the voice
8552 14494096 void stop_sfx(int32_t index)
8553 {
8554
3/4
✓ Branch 0 taken 14247069 times.
✓ Branch 1 taken 247027 times.
✓ Branch 2 taken 14247069 times.
✗ Branch 3 not taken.
14494096 if(index<=0 || index>=WAV_COUNT)
8555 247027 return;
8556
8557
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14247036 times.
14247069 if(sfx_voice[index]!=-1)
8558 {
8559 33 deallocate_voice(sfx_voice[index]);
8560 33 sfx_voice[index]=-1;
8561 33 }
8562 14494096 }
8563
8564 // Stops SFX played by Hero's item of the given family
8565 130619 void stop_item_sfx(int32_t family)
8566 {
8567 130619 int32_t id=current_item_id(family);
8568
8569
2/2
✓ Branch 0 taken 129519 times.
✓ Branch 1 taken 1100 times.
130619 if(id<0)
8570 129519 return;
8571
8572 1100 stop_sfx(itemsbuf[id].usesound);
8573 130619 }
8574
8575 8010 void kill_sfx()
8576 {
8577
2/2
✓ Branch 0 taken 2050560 times.
✓ Branch 1 taken 8010 times.
2058570 for(int32_t i=0; i<WAV_COUNT; i++)
8578
2/2
✓ Branch 0 taken 2050504 times.
✓ Branch 1 taken 56 times.
2050616 if(sfx_voice[i]!=-1)
8579 {
8580 56 deallocate_voice(sfx_voice[i]);
8581 56 sfx_voice[i]=-1;
8582 56 }
8583 8010 }
8584
8585 1172997 int32_t pan(int32_t x)
8586 {
8587
1/4
✓ Branch 0 taken 1172997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172997 switch(pan_style)
8588 {
8589 case 0:
8590 return 128;
8591
8592 case 1:
8593 1172997 return vbound((x>>1)+68,0,255);
8594
8595 case 2:
8596 return vbound(((x*3)>>2)+36,0,255);
8597 }
8598
8599 return vbound(x,0,255);
8600 1172997 }
8601
8602 /*******************************/
8603 /******* Input Handlers ********/
8604 /*******************************/
8605
8606 49898772 bool joybtn(int32_t b)
8607 {
8608
1/2
✓ Branch 0 taken 49898772 times.
✗ Branch 1 not taken.
49898772 if(b == 0)
8609 return false;
8610
1/2
✓ Branch 0 taken 49898772 times.
✗ Branch 1 not taken.
49898772 if (b-1 >= joy[joystick_index].num_buttons)
8611 49898772 return false;
8612
8613 return joy[joystick_index].button[b-1].b !=0;
8614 49898772 }
8615
8616 bool joystick(int32_t s)
8617 {
8618 if(s < 0)
8619 return false;
8620 if (s >= joy[joystick_index].num_sticks)
8621 return false;
8622
8623 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8624 {
8625 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8626 return true;
8627 }
8628 return false;
8629 }
8630
8631 const char* joybtn_name(int32_t b)
8632 {
8633 if (b <= 0 || b > joy[joystick_index].num_buttons)
8634 return "";
8635
8636 return joy[joystick_index].button[b-1].name;
8637 }
8638
8639 const char* joystick_name(int32_t s)
8640 {
8641 if (s < 0 || s >= joy[joystick_index].num_sticks)
8642 return "";
8643
8644 return joy[joystick_index].stick[s].name;
8645 }
8646
8647 int32_t button_pressed()
8648 {
8649 if (joystick_index >= MAX_JOYSTICKS)
8650 return 0;
8651
8652 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8653 {
8654 if(joybtn(i))
8655 return i;
8656 }
8657
8658 return 0;
8659 }
8660
8661 int32_t next_press_key();
8662
8663 int32_t next_joy_input(bool buttons)
8664 {
8665 clear_keybuf();
8666
8667 //first, we need to wait until they're pressing no buttons
8668 for(;;)
8669 {
8670 if(keypressed())
8671 {
8672 switch(readkey()>>8)
8673 {
8674 case KEY_ESC:
8675 return -1;
8676
8677 case KEY_SPACE:
8678 return 0;
8679 }
8680 }
8681
8682 poll_joystick();
8683 bool done = true;
8684
8685 if (buttons)
8686 {
8687 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8688 {
8689 if(joybtn(i)) done = false;
8690 }
8691 }
8692 else
8693 {
8694 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8695 {
8696 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8697 return -2;
8698 }
8699 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8700 {
8701 if(joystick(i)) done = false;
8702 }
8703 }
8704
8705 if(done) break;
8706 rest(1);
8707 }
8708
8709 //now, we need to wait for them to press any button
8710 for(;;)
8711 {
8712 if(keypressed())
8713 {
8714 switch(readkey()>>8)
8715 {
8716 case KEY_ESC:
8717 return -1;
8718
8719 case KEY_SPACE:
8720 return 0;
8721 }
8722 }
8723
8724 poll_joystick();
8725
8726 if (buttons)
8727 {
8728 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8729 {
8730 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8731 return -2;
8732 }
8733 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8734 {
8735 if(joybtn(i))
8736 return i;
8737 }
8738 }
8739 else
8740 {
8741 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8742 {
8743 if(joystick(i))
8744 return i;
8745 }
8746 }
8747 rest(1);
8748 }
8749 }
8750
8751 7415325 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8752 {
8753
2/2
✓ Branch 0 taken 7389040 times.
✓ Branch 1 taken 26285 times.
7415325 bool ret = btn && !flag;
8754 7415325 flag = rawbtn;
8755
8756 7415325 return ret;
8757 }
8758 373604963 static bool rButton(bool &btn, bool &flag)
8759 {
8760
2/2
✓ Branch 0 taken 359836569 times.
✓ Branch 1 taken 13768394 times.
373604963 bool ret = btn && !flag;
8761 373604963 flag = btn;
8762
8763 373604963 return ret;
8764 }
8765 4577206 static bool rButtonPeek(bool btn, bool flag)
8766 {
8767
2/2
✓ Branch 0 taken 4236933 times.
✓ Branch 1 taken 340273 times.
4577206 if(!btn)
8768 {
8769 4236933 return false;
8770 }
8771
2/2
✓ Branch 0 taken 33326 times.
✓ Branch 1 taken 306947 times.
340273 else if(!flag)
8772 {
8773 33326 return true;
8774 }
8775
8776 306947 return false;
8777 4577206 }
8778
8779 // Updated only by keyboard/gamepad.
8780 // If in replay mode, this is set directly by the replay system.
8781 // This should never be read from directly - use control_state instead.
8782 bool raw_control_state[ZC_CONTROL_STATES];
8783
8784 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8785 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8786 // lasts until the next call to load_control_state.
8787 bool control_state[ZC_CONTROL_STATES];
8788 bool disable_control[ZC_CONTROL_STATES];
8789 bool drunk_toggle_state[11];
8790 bool disabledKeys[127];
8791 bool KeyInput[127];
8792 bool KeyPress[127];
8793
8794 bool key_current_frame[127];
8795 bool key_previous_frame[127];
8796
8797 static bool key_system[127];
8798 static bool key_system_previous[127];
8799 static bool key_system_press[127];
8800
8801 bool button_press[ZC_CONTROL_STATES];
8802 bool button_hold[ZC_CONTROL_STATES];
8803
8804 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8805 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8806 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8807 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8808 #define STICK_PRECISION 56 //define your own sensitivity
8809
8810 15510129 void load_control_state()
8811 {
8812 15510129 load_control_called_this_frame = true;
8813
8814
2/2
✓ Branch 0 taken 12380497 times.
✓ Branch 1 taken 3129632 times.
15510129 if (replay_version_check(8, 11))
8815 {
8816
2/2
✓ Branch 0 taken 56333376 times.
✓ Branch 1 taken 3129632 times.
59463008 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8817 56333376 down_control_states[i] = raw_control_state[i];
8818 3129632 }
8819
8820
2/2
✓ Branch 0 taken 15510108 times.
✓ Branch 1 taken 21 times.
15510129 if (!replay_is_replaying())
8821 {
8822
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8823
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8824
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8825
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8836
8837
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(num_joysticks != 0)
8838 {
8839 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8840 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8841 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8842 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8843 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8844 }
8845 else
8846 {
8847 21 raw_control_state[14] = false;
8848 21 raw_control_state[15] = false;
8849 21 raw_control_state[16] = false;
8850 21 raw_control_state[17] = false;
8851 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8852 }
8853 21 }
8854
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15510124 times.
15510129 if (replay_is_active())
8855 {
8856
2/2
✓ Branch 0 taken 1211700 times.
✓ Branch 1 taken 14298424 times.
15510124 if (replay_get_version() < 3)
8857 1211700 replay_poll();
8858
4/4
✓ Branch 0 taken 14298403 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12536409 times.
✓ Branch 3 taken 1761994 times.
14298424 else if (replay_is_replaying() && replay_get_version() < 6)
8859 1761994 replay_peek_input();
8860
4/4
✓ Branch 0 taken 12536409 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 9406777 times.
✓ Branch 3 taken 3129632 times.
12536430 else if (replay_is_replaying() && replay_version_check(8, 11))
8861 3129632 replay_peek_input();
8862
2/2
✓ Branch 0 taken 14243612 times.
✓ Branch 1 taken 1266512 times.
15510124 if (replay_get_version() == 8)
8863 1266512 update_keys();
8864 15510124 }
8865
8866 // Some test replay files were made before a serious input bug was fixed, so instead
8867 // of re-doing them or tossing them out, just check for that zplay version.
8868
3/4
✓ Branch 0 taken 15510119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 15388219 times.
15510129 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8869
2/2
✓ Branch 0 taken 279182142 times.
✓ Branch 1 taken 15510119 times.
294692261 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8870 {
8871 279182142 control_state[i] = raw_control_state[i];
8872
4/4
✓ Branch 0 taken 53035164 times.
✓ Branch 1 taken 226146978 times.
✓ Branch 2 taken 2612094 times.
✓ Branch 3 taken 50423070 times.
279182142 if (botched_input && !control_state[i])
8873 50423070 down_control_states[i] = false;
8874 279182142 }
8875 15510119 bool did_bad_cutscene_btn = false;
8876
2/2
✓ Branch 0 taken 15510119 times.
✓ Branch 1 taken 279182142 times.
294692261 for(int q = 0; q < 18; ++q)
8877
4/4
✓ Branch 0 taken 13202084 times.
✓ Branch 1 taken 265980058 times.
✓ Branch 2 taken 13199767 times.
✓ Branch 3 taken 2317 times.
279184459 if(control_state[q] && !active_cutscene.can_button(q))
8878 {
8879 2317 control_state[q] = false;
8880 2317 did_bad_cutscene_btn = true;
8881 2317 }
8882
2/2
✓ Branch 0 taken 15508459 times.
✓ Branch 1 taken 1660 times.
15510119 if(did_bad_cutscene_btn)
8883 1660 active_cutscene.error();
8884
8885 15510119 button_press[0]=rButton(control_state[0],button_hold[0]);
8886 15510119 button_press[1]=rButton(control_state[1],button_hold[1]);
8887 15510119 button_press[2]=rButton(control_state[2],button_hold[2]);
8888 15510119 button_press[3]=rButton(control_state[3],button_hold[3]);
8889 15510119 button_press[4]=rButton(control_state[4],button_hold[4]);
8890 15510119 button_press[5]=rButton(control_state[5],button_hold[5]);
8891 15510119 button_press[6]=rButton(control_state[6],button_hold[6]);
8892 15510119 button_press[7]=rButton(control_state[7],button_hold[7]);
8893 15510119 button_press[8]=rButton(control_state[8],button_hold[8]);
8894 15510119 button_press[9]=rButton(control_state[9],button_hold[9]);
8895 15510119 button_press[10]=rButton(control_state[10],button_hold[10]);
8896 15510119 button_press[11]=rButton(control_state[11],button_hold[11]);
8897 15510119 button_press[12]=rButton(control_state[12],button_hold[12]);
8898 15510119 button_press[13]=rButton(control_state[13],button_hold[13]);
8899 15510119 button_press[14]=rButton(control_state[14],button_hold[14]);
8900 15510119 button_press[15]=rButton(control_state[15],button_hold[15]);
8901 15510119 button_press[16]=rButton(control_state[16],button_hold[16]);
8902 15510119 button_press[17]=rButton(control_state[17],button_hold[17]);
8903 15510119 }
8904
8905 // Returns true if any game key is pressed. This is needed because keypressed()
8906 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8907 77865243 bool zc_key_pressed()
8908 //may also need to use zc_getrawkey
8909 {
8910
7/10
✓ Branch 0 taken 62881728 times.
✓ Branch 1 taken 14983515 times.
✓ Branch 2 taken 14983515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14983515 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12268337 times.
✓ Branch 7 taken 12268337 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4911000 times.
82776243 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8911
4/6
✓ Branch 0 taken 12268337 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12268337 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9340407 times.
✓ Branch 5 taken 9340407 times.
12268337 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8912
4/6
✓ Branch 0 taken 9340407 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9340407 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6189391 times.
✓ Branch 5 taken 6189391 times.
9340407 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8913
4/6
✓ Branch 0 taken 6189391 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6189391 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5314722 times.
✓ Branch 5 taken 5314722 times.
6189391 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8914
1/2
✓ Branch 0 taken 5314722 times.
✗ Branch 1 not taken.
5314722 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8915
3/4
✓ Branch 0 taken 5128974 times.
✓ Branch 1 taken 185748 times.
✓ Branch 2 taken 5128974 times.
✗ Branch 3 not taken.
5314722 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8916
3/4
✓ Branch 0 taken 4982846 times.
✓ Branch 1 taken 146128 times.
✓ Branch 2 taken 4982846 times.
✗ Branch 3 not taken.
5128974 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8917
3/4
✓ Branch 0 taken 4961976 times.
✓ Branch 1 taken 20870 times.
✓ Branch 2 taken 4961976 times.
✗ Branch 3 not taken.
4982846 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8918
3/4
✓ Branch 0 taken 4935617 times.
✓ Branch 1 taken 26359 times.
✓ Branch 2 taken 4935617 times.
✗ Branch 3 not taken.
4961976 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8919
3/4
✓ Branch 0 taken 4928332 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 4928332 times.
✗ Branch 3 not taken.
4935617 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8920
3/4
✓ Branch 0 taken 4912942 times.
✓ Branch 1 taken 15390 times.
✓ Branch 2 taken 4912942 times.
✗ Branch 3 not taken.
4928332 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8921
3/4
✓ Branch 0 taken 4911094 times.
✓ Branch 1 taken 1848 times.
✓ Branch 2 taken 4911094 times.
✗ Branch 3 not taken.
4912942 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8922
3/4
✓ Branch 0 taken 4911059 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4911059 times.
✗ Branch 3 not taken.
4911094 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8923
2/2
✓ Branch 0 taken 4911000 times.
✓ Branch 1 taken 59 times.
4911059 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8924 139179957 return true;
8925
8926 4911000 return false;
8927 18327501 }
8928
8929 294907345 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8930 {
8931 294907345 bool ret = false, drunkstate = false, rawret = false;;
8932 294907345 bool* flag = &down_control_states[btn];
8933
2/7
✓ Branch 0 taken 276561035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18346310 times.
294907345 switch(btn)
8934 {
8935 case btnF12:
8936 ret = zc_getkey(KEY_F12, ignoreDisable);
8937 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8938 eatEntirely = false;
8939 break;
8940 case btnF11:
8941 ret = zc_getkey(KEY_F11, ignoreDisable);
8942 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8943 eatEntirely = false;
8944 break;
8945 case btnF5:
8946 ret = zc_getkey(KEY_F5, ignoreDisable);
8947 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8948 eatEntirely = false;
8949 break;
8950 case btnQ:
8951 ret = zc_getkey(KEY_Q, ignoreDisable);
8952 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8953 eatEntirely = false;
8954 break;
8955 case btnI:
8956 ret = zc_getkey(KEY_I, ignoreDisable);
8957 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8958 eatEntirely = false;
8959 break;
8960 case btnM:
8961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18346310 times.
18346310 if(FFCore.kb_typing_mode) return false;
8962 18346310 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8963 18346310 eatEntirely = false;
8964 18346310 break;
8965 default: //control_state[] index
8966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276561035 times.
276561035 if(FFCore.kb_typing_mode) return false;
8967
6/6
✓ Branch 0 taken 275196745 times.
✓ Branch 1 taken 1364290 times.
✓ Branch 2 taken 16875342 times.
✓ Branch 3 taken 258321403 times.
✓ Branch 4 taken 16875189 times.
✓ Branch 5 taken 153 times.
276561035 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8968
2/2
✓ Branch 0 taken 15741590 times.
✓ Branch 1 taken 260819292 times.
276560882 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8969
4/4
✓ Branch 0 taken 245753529 times.
✓ Branch 1 taken 30807506 times.
✓ Branch 2 taken 5480 times.
✓ Branch 3 taken 30802026 times.
307368541 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8970 276561035 rawret = raw_control_state[btn];
8971 276561035 }
8972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294907345 times.
294907345 assert(flag);
8973
2/2
✓ Branch 0 taken 188491993 times.
✓ Branch 1 taken 106415352 times.
294907345 if(press)
8974 {
8975
2/2
✓ Branch 0 taken 4577206 times.
✓ Branch 1 taken 101838146 times.
106415352 if(peek)
8976 4577206 ret = rButtonPeek(ret, *flag);
8977
2/2
✓ Branch 0 taken 94422821 times.
✓ Branch 1 taken 7415325 times.
101838146 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8978 7415325 else ret = rButton(ret, *flag, rawret);
8979 106415352 }
8980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294907345 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294907345 if(eatEntirely && ret) control_state[btn] = false;
8981
4/4
✓ Branch 0 taken 220356042 times.
✓ Branch 1 taken 74551303 times.
✓ Branch 2 taken 220355961 times.
✓ Branch 3 taken 81 times.
294907345 if(drunk && drunkstate) ret = !ret;
8982 294907345 return ret;
8983 294907345 }
8984
8985 14817492 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8986 {
8987 14817492 byte ret = 0;
8988
2/2
✓ Branch 0 taken 10463199 times.
✓ Branch 1 taken 4354293 times.
14817492 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8989
2/2
✓ Branch 0 taken 14610263 times.
✓ Branch 1 taken 207229 times.
14817492 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8990
2/2
✓ Branch 0 taken 14610710 times.
✓ Branch 1 taken 206782 times.
14817492 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8991
2/2
✓ Branch 0 taken 14610710 times.
✓ Branch 1 taken 206782 times.
14817492 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8992
2/2
✓ Branch 0 taken 14610710 times.
✓ Branch 1 taken 206782 times.
14817492 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8993
2/2
✓ Branch 0 taken 14610710 times.
✓ Branch 1 taken 206782 times.
14817492 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8994
2/2
✓ Branch 0 taken 14610710 times.
✓ Branch 1 taken 206782 times.
14817492 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8995
2/2
✓ Branch 0 taken 14610595 times.
✓ Branch 1 taken 206897 times.
14817492 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8996 14817492 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8997 }
8998
8999 7515 byte checkIntBtnVal(byte intbtn, byte vals)
9000 {
9001 7515 return intbtn&vals;
9002 }
9003
9004 3711649 bool Up()
9005 {
9006 3711649 return getInput(btnUp);
9007 }
9008 728445 bool Down()
9009 {
9010 728445 return getInput(btnDown);
9011 }
9012 982865 bool Left()
9013 {
9014 982865 return getInput(btnLeft);
9015 }
9016 1044199 bool Right()
9017 {
9018 1044199 return getInput(btnRight);
9019 }
9020 532139 bool cAbtn()
9021 {
9022 532139 return getInput(btnA);
9023 }
9024 3306978 bool cBbtn()
9025 {
9026 3306978 return getInput(btnB);
9027 }
9028 bool cSbtn()
9029 {
9030 return getInput(btnS);
9031 }
9032 208608 bool cLbtn()
9033 {
9034 208608 return getInput(btnL);
9035 }
9036 208608 bool cRbtn()
9037 {
9038 208608 return getInput(btnR);
9039 }
9040 bool cPbtn()
9041 {
9042 return getInput(btnP);
9043 }
9044 bool cEx1btn()
9045 {
9046 return getInput(btnEx1);
9047 }
9048 bool cEx2btn()
9049 {
9050 return getInput(btnEx2);
9051 }
9052 bool cEx3btn()
9053 {
9054 return getInput(btnEx3);
9055 }
9056 bool cEx4btn()
9057 {
9058 return getInput(btnEx4);
9059 }
9060 bool AxisUp()
9061 {
9062 return getInput(btnAxisUp);
9063 }
9064 bool AxisDown()
9065 {
9066 return getInput(btnAxisDown);
9067 }
9068 bool AxisLeft()
9069 {
9070 return getInput(btnAxisLeft);
9071 }
9072 bool AxisRight()
9073 {
9074 return getInput(btnAxisRight);
9075 }
9076
9077 bool cMbtn()
9078 {
9079 return getInput(btnM);
9080 }
9081 bool cF12()
9082 {
9083 return getInput(btnF12);
9084 }
9085 bool cF11()
9086 {
9087 return getInput(btnF11);
9088 }
9089 bool cF5()
9090 {
9091 return getInput(btnF5);
9092 }
9093 bool cQ()
9094 {
9095 return getInput(btnQ);
9096 }
9097 bool cI()
9098 {
9099 return getInput(btnI);
9100 }
9101
9102 208304 bool rUp()
9103 {
9104 208304 return getInput(btnUp, true);
9105 }
9106 208096 bool rDown()
9107 {
9108 208096 return getInput(btnDown, true);
9109 }
9110 207900 bool rLeft()
9111 {
9112 207900 return getInput(btnLeft, true);
9113 }
9114 207171 bool rRight()
9115 {
9116 207171 return getInput(btnRight, true);
9117 }
9118 6570 bool rAbtn()
9119 {
9120 6570 return getInput(btnA, true);
9121 }
9122 4619 bool rBbtn()
9123 {
9124 4619 return getInput(btnB, true);
9125 }
9126 14380435 bool rSbtn()
9127 {
9128 14380435 return getInput(btnS, true);
9129 }
9130 18327501 bool rMbtn()
9131 {
9132 18327501 return getInput(btnM, true);
9133 }
9134 185250 bool rLbtn()
9135 {
9136 185250 return getInput(btnL, true);
9137 }
9138 185245 bool rRbtn()
9139 {
9140 185245 return getInput(btnR, true);
9141 }
9142 14381168 bool rPbtn()
9143 {
9144 14381168 return getInput(btnP, true);
9145 }
9146 bool rEx1btn()
9147 {
9148 return getInput(btnEx1, true);
9149 }
9150 bool rEx2btn()
9151 {
9152 return getInput(btnEx2, true);
9153 }
9154 195896 bool rEx3btn()
9155 {
9156 195896 return getInput(btnEx3, true);
9157 }
9158 195896 bool rEx4btn()
9159 {
9160 195896 return getInput(btnEx4, true);
9161 }
9162 bool rAxisUp()
9163 {
9164 return getInput(btnAxisUp, true);
9165 }
9166 bool rAxisDown()
9167 {
9168 return getInput(btnAxisDown, true);
9169 }
9170 bool rAxisLeft()
9171 {
9172 return getInput(btnAxisLeft, true);
9173 }
9174 bool rAxisRight()
9175 {
9176 return getInput(btnAxisRight, true);
9177 }
9178
9179 bool rF11()
9180 {
9181 return getInput(btnF11, true);
9182 }
9183 bool rQ()
9184 {
9185 return getInput(btnQ, true);
9186 }
9187 bool rI()
9188 {
9189 return getInput(btnI, true);
9190 }
9191
9192 36623307 bool DrunkUp()
9193 {
9194 36623307 return getInput(btnUp, false, true);
9195 }
9196 33421566 bool DrunkDown()
9197 {
9198 33421566 return getInput(btnDown, false, true);
9199 }
9200 19596901 bool DrunkLeft()
9201 {
9202 19596901 return getInput(btnLeft, false, true);
9203 }
9204 16672144 bool DrunkRight()
9205 {
9206 16672144 return getInput(btnRight, false, true);
9207 }
9208 15785428 bool DrunkcAbtn()
9209 {
9210 15785428 return getInput(btnA, false, true);
9211 }
9212 15225870 bool DrunkcBbtn()
9213 {
9214 15225870 return getInput(btnB, false, true);
9215 }
9216 14172376 bool DrunkcEx1btn()
9217 {
9218 14172376 return getInput(btnEx1, false, true);
9219 }
9220 14171008 bool DrunkcEx2btn()
9221 {
9222 14171008 return getInput(btnEx2, false, true);
9223 }
9224 bool DrunkcSbtn()
9225 {
9226 return getInput(btnS, false, true);
9227 }
9228 bool DrunkcMbtn()
9229 {
9230 return getInput(btnM, false, true);
9231 }
9232 bool DrunkcLbtn()
9233 {
9234 return getInput(btnL, false, true);
9235 }
9236 bool DrunkcRbtn()
9237 {
9238 return getInput(btnR, false, true);
9239 }
9240 bool DrunkcPbtn()
9241 {
9242 return getInput(btnP, false, true);
9243 }
9244
9245 bool DrunkrUp()
9246 {
9247 return getInput(btnUp, true, true);
9248 }
9249 bool DrunkrDown()
9250 {
9251 return getInput(btnDown, true, true);
9252 }
9253 bool DrunkrLeft()
9254 {
9255 return getInput(btnLeft, true, true);
9256 }
9257 bool DrunkrRight()
9258 {
9259 return getInput(btnRight, true, true);
9260 }
9261 11844225 bool DrunkrAbtn()
9262 {
9263 11844225 return getInput(btnA, true, true);
9264 }
9265 11872814 bool DrunkrBbtn()
9266 {
9267 11872814 return getInput(btnB, true, true);
9268 }
9269 502081 bool DrunkrEx1btn()
9270 {
9271 502081 return getInput(btnEx1, true, true);
9272 }
9273 501902 bool DrunkrEx2btn()
9274 {
9275 501902 return getInput(btnEx2, true, true);
9276 }
9277 bool DrunkrEx3btn()
9278 {
9279 return getInput(btnEx3, true, true);
9280 }
9281 bool DrunkrEx4btn()
9282 {
9283 return getInput(btnEx4, true, true);
9284 }
9285 bool DrunkrSbtn()
9286 {
9287 return getInput(btnS, true, true);
9288 }
9289 bool DrunkrMbtn()
9290 {
9291 return getInput(btnM, true, true);
9292 }
9293 12910078 bool DrunkrLbtn()
9294 {
9295 12910078 return getInput(btnL, true, true);
9296 }
9297 12904773 bool DrunkrRbtn()
9298 {
9299 12904773 return getInput(btnR, true, true);
9300 }
9301 bool DrunkrPbtn()
9302 {
9303 return getInput(btnP, true, true);
9304 }
9305
9306 18809 void eat_buttons()
9307 {
9308 18809 getInput(btnA, true, false, true);
9309 18809 getInput(btnB, true, false, true);
9310 18809 getInput(btnS, true, false, true);
9311 18809 getInput(btnM, true, false, true);
9312 18809 getInput(btnL, true, false, true);
9313 18809 getInput(btnR, true, false, true);
9314 18809 getInput(btnP, true, false, true);
9315 18809 getInput(btnEx1, true, false, true);
9316 18809 getInput(btnEx2, true, false, true);
9317 18809 getInput(btnEx3, true, false, true);
9318 18809 getInput(btnEx4, true, false, true);
9319 18809 }
9320
9321 // Is true for the _first frame_ of a key press.
9322 // But! it is possible that a script manually sets the value of KeyPress,
9323 // in which case it will be restored to the "true" value based on `key_current_frame`
9324 // and `key_previous_frame` on the next frame.
9325 61 bool zc_readkey(int32_t k, bool ignoreDisable)
9326 {
9327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(ignoreDisable) return KeyPress[k];
9328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 switch(k)
9329 {
9330 case KEY_F7:
9331 case KEY_F8:
9332 case KEY_F9:
9333 return KeyPress[k];
9334
9335 default:
9336
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 15 times.
61 return KeyPress[k] && !disabledKeys[k];
9337 }
9338 61 }
9339
9340 // Is true for _every frame_ a key is held down.
9341 // But! it is possible that a script manually sets the value of KeyInput,
9342 // in which case it will be restored to the "true" value based on `key_current_frame`
9343 // on the next frame.
9344 bool zc_getkey(int32_t k, bool ignoreDisable)
9345 {
9346 if(ignoreDisable) return KeyInput[k];
9347 switch(k)
9348 {
9349 case KEY_F7:
9350 case KEY_F8:
9351 case KEY_F9:
9352 return KeyInput[k];
9353
9354 default:
9355 return KeyInput[k] && !disabledKeys[k];
9356 }
9357 }
9358
9359 // Reads (and then clears) the current frame key state directly.
9360 // Scripts can also modify `key_current_frame`.
9361 933 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9362 {
9363
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 931 times.
933 if(zc_getrawkey(k, ignoreDisable))
9364 {
9365 2 _key[k]=key[k]=key_current_frame[k]=0;
9366 2 return true;
9367 }
9368 931 _key[k]=key[k]=key_current_frame[k]=0;
9369 931 return false;
9370 933 }
9371
9372 // Reads the current frame key state directly.
9373 // Scripts can also modify `key_current_frame`.
9374 124444250 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9375 {
9376
2/2
✓ Branch 0 taken 106116627 times.
✓ Branch 1 taken 18327623 times.
124444250 if(ignoreDisable) return key_current_frame[k];
9377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327623 times.
18327623 switch(k)
9378 {
9379 case KEY_F7:
9380 case KEY_F8:
9381 case KEY_F9:
9382 return key_current_frame[k];
9383
9384 default:
9385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18327623 times.
18327623 return key_current_frame[k] && !disabledKeys[k];
9386 }
9387 124444250 }
9388
9389 // Only used for a handful of keys, like tilde and Function keys.
9390 // This state is never read within the game.
9391 // It exists so that all keyboard input still functions during replay,
9392 // without inadvertently doing things like toggling throttling if the player
9393 // presses ~
9394 22442 bool zc_get_system_key(int32_t k)
9395 {
9396 22442 return key_system[k];
9397 }
9398
9399 // True for the _first_ frame of a key press.
9400 164947509 bool zc_read_system_key(int32_t k)
9401 {
9402 164947509 return key_system_press[k];
9403 }
9404
9405 2327592627 bool is_system_key(int32_t k)
9406 {
9407
2/2
✓ Branch 0 taken 2162645118 times.
✓ Branch 1 taken 164947509 times.
2327592627 switch (k)
9408 {
9409 case KEY_BACKQUOTE:
9410 case KEY_CLOSEBRACE:
9411 case KEY_END:
9412 case KEY_HOME:
9413 case KEY_OPENBRACE:
9414 case KEY_PGDN:
9415 case KEY_PGUP:
9416 case KEY_TAB:
9417 case KEY_TILDE:
9418 164947509 return true;
9419 }
9420 2162645118 return is_Fkey(k);
9421 2327592627 }
9422
9423 18327501 void update_system_keys()
9424 {
9425
2/2
✓ Branch 0 taken 2327592627 times.
✓ Branch 1 taken 18327501 times.
2345920128 for (int32_t q = 0; q < 127; ++q)
9426 {
9427
2/2
✓ Branch 0 taken 384877521 times.
✓ Branch 1 taken 1942715106 times.
2327592627 if (!is_system_key(q))
9428 1942715106 continue;
9429
9430 384877521 key_system[q] = key[q];
9431
1/2
✓ Branch 0 taken 384877521 times.
✗ Branch 1 not taken.
384877521 key_system_press[q] = key_system[q] && !key_system_previous[q];
9432 384877521 key_system_previous[q] = key_system[q];
9433 384877521 }
9434 18327501 }
9435
9436 19594013 void update_keys()
9437 {
9438
2/2
✓ Branch 0 taken 2488439651 times.
✓ Branch 1 taken 19594013 times.
2508033664 for (int32_t q = 0; q < 127; ++q)
9439 {
9440 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9441
2/2
✓ Branch 0 taken 2488426951 times.
✓ Branch 1 taken 12700 times.
2488439651 if (!replay_is_replaying())
9442 12700 key_current_frame[q] = key[q];
9443
9444
2/2
✓ Branch 0 taken 2469334747 times.
✓ Branch 1 taken 19104904 times.
2488439651 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9445 2488439651 KeyInput[q] = key_current_frame[q];
9446 2488439651 key_previous_frame[q] = key_current_frame[q];
9447 2488439651 }
9448 19594013 }
9449
9450 bool zc_disablekey(int32_t k, bool val)
9451 {
9452 switch(k)
9453 {
9454 case KEY_F7:
9455 case KEY_F8:
9456 case KEY_F9:
9457 return false;
9458
9459 default:
9460 disabledKeys[k] = val;
9461 return true;
9462 }
9463 }
9464
9465 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9466 {
9467 timer=timer;
9468 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9469 }
9470